|
楼主 |
发表于 2010-7-5 14:27:40
|
显示全部楼层
修改 postfix 配置文件:
1 cd /etc/postfix
2 mv main.cf main.cf.bak
3 vi main.cf
加入以下内容:
001 queue_directory = /var/spool/postfix
002 command_directory = /usr/sbin
003 daemon_directory = /usr/libexec/postfix
004 data_directory = /var/lib/postfix
005
006 mail_owner = postfix
007
008 #default_privs = nobody
009
010 myhostname = mail.howpick.com #修改为你自己的主机名称,注意这里的设置不能和Mysql里面加入的域名重复。
011 #myhostname = virtual.domain.tld
012
013 mydomain = howpick.com #修改为你自己的域名。
014
015 myorigin = $myhostname
016 #myorigin = $mydomain
017
018 inet_interfaces = all
019 #inet_interfaces = $myhostname
020 #inet_interfaces = $myhostname, localhost
021
022 #proxy_interfaces =
023 #proxy_interfaces = 1.2.3.4
024
025 mydestination = $myhostname, localhost.$mydomain, localhost
026 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
027 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
028 # mail.$mydomain, www.$mydomain, ftp.$mydomain
029
030 #local_recipient_maps = unix:passwd.byname $alias_maps
031 #local_recipient_maps = proxy:unix:passwd.byname $alias_maps
032 #local_recipient_maps =
033
034 unknown_local_recipient_reject_code = 550
035
036 #relay_domains = $mydestination
037
038 #relayhost = $mydomain
039 #relayhost = [gateway.my.domain]
040 #relayhost = [mailserver.isp.tld]
041 #relayhost = uucphost
042 #relayhost = [an.ip.add.ress]
043
044 #relay_recipient_maps = hash:/etc/postfix/relay_recipients
045
046 #in_flow_delay = 1s
047
048 #alias_maps = dbm:/etc/aliases
049 #alias_maps = hash:/etc/aliases
050 #alias_maps = hash:/etc/aliases, nis:mail.aliases
051 #alias_maps = netinfo:/aliases
052
053 #alias_database = dbm:/etc/aliases
054 #alias_database = dbm:/etc/mail/aliases
055 #alias_database = hash:/etc/aliases
056 #alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
057
058 #recipient_delimiter = +
059 #
060 #home_mailbox = Mailbox
061 #home_mailbox = Maildir/
062
063 #mail_spool_directory = /var/mail
064 #mail_spool_directory = /var/spool/mail
065
066 #mailbox_command = /some/where/procmail
067 #mailbox_command = /some/where/procmail -a "$EXTENSION"
068
069 #mailbox_transport = lmtp:unix:/file/name
070 #mailbox_transport = cyrus
071
072 #fallback_transport = lmtp:unix:/file/name
073 #fallback_transport = cyrus
074 #fallback_transport =
075
076 #luser_relay = $user@other.host
077 #luser_relay = $local@other.host
078 #luser_relay = admin+$local
079
080 #============================================
081 # JUNK MAIL CONTROLS
082 #============================================
083 #header_checks = regexp:/etc/postfix/header_checks
084
085 # FAST ETRN SERVICE
086 #
087 #fast_flush_domains = $relay_domains
088
089 # SHOW SOFTWARE VERSION OR NOT
090 #
091 #smtpd_banner = $myhostname ESMTP $mail_name
092 #smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
093
094 # PARALLEL DELIVERY TO THE SAME DESTINATION
095 #
096 #local_destination_concurrency_limit = 2
097 #default_destination_concurrency_limit = 20
098
099 debug_peer_level = 2
100
101 #debug_peer_list = 127.0.0.1
102 #debug_peer_list = some.domain
103
104 #debugger_command =
105 # PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
106 # ddd $daemon_directory/$process_name $process_id & sleep 5
107
108 debugger_command =
109 PATH=/bin:/usr/bin:/usr/local/bin; export PATH; (echo cont;
110 echo where) | gdb $daemon_directory/$process_name $process_id 2>&1
111 >$config_directory/$process_name.$process_id.log & sleep 5
112
113 # debugger_command =
114 # PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH; screen
115 # -dmS $process_name gdb $daemon_directory/$process_name
116 # $process_id & sleep 1
117
118 sendmail_path = /usr/sbin/sendmail
119
120 newaliases_path = /usr/bin/newaliases
121
122 mailq_path = /usr/bin/mailq
123
124 setgid_group = postdrop
125
126 # html_directory: The location of the Postfix HTML documentation.
127 #
128 html_directory = no
129
130 # manpage_directory: The location of the Postfix on-line manual pages.
131 #
132 manpage_directory = /usr/local/man
133
134 # sample_directory: The location of the Postfix sample configuration files.
135 # This parameter is obsolete as of Postfix 2.1.
136 #
137 sample_directory = /etc/postfix
138
139 # readme_directory: The location of the Postfix README files.
140 #
141 readme_directory = no
142
143 #=====================Vritual Mailbox settings=========================
144 virtual_mailbox_base = /home/vmail/
145 virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
146 virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
147 virtual_alias_domains =
148 virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
149 virtual_uid_maps = static:12345 # 这里要和你添加的postfix用户的uid一致, 查看方法为 cat /etc/passwd
150 virtual_gid_maps = static:12345 # 这里要和你添加的postfix用户的gid一致, 查看方法为 cat /etc/passwd
151 virtual_minimum_uid = 501 # 这里要保证nginx/apache可以修改/home/vmail目录, 查看方法为 cat /etc/passwd
152 virtual_transport = virtual
153 maildrop_destination_recipient_limit = 1
154 maildrop_destination_concurrency_limit = 1
155
156 #====================QUOTA========================
157 message_size_limit = 5242880
158 #每个邮件最大尺寸5M
159 mailbox_size_limit = 209715200
160 #邮箱大小限制200M
161 virtual_mailbox_limit = 209715200
162 #虚拟邮箱大小限制200M
163 virtual_create_maildirsize = yes
164 virtual_mailbox_extended = yes
165 virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_limit_maps.cf
166 virtual_mailbox_limit_override = yes
167 virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
168 virtual_overquota_bounce = yes
169
170 #====================SASL========================
171 smtpd_sasl_type = dovecot
172 #使用dovecot进行验证
173 smtpd_sasl_path = /var/run/dovecot/auth-client
174 #与dovecot.conf中如下的的path一致
175 broken_sasl_auth_clients = yes
176 smtpd_recipient_restrictions = permit_mynetworks,
177 permit_sasl_authenticated,
178 reject_invalid_hostname,
179 reject_non_fqdn_hostname,
180 reject_unknown_sender_domain,
181 reject_non_fqdn_sender,
182 reject_non_fqdn_recipient,
183 reject_unknown_recipient_domain,
184 reject_unauth_pipelining,
185 reject_unauth_destination,
186 permit
187
188 #列出本地用户的列表,以便验证 From: 本地域 To: 本地域
189 #smtpd_sender_login_maps =
190 # mysql:/etc/postfix/mysql_virtual_sender_maps.cf,
191 # mysql:/etc/postfix/mysql_virtual_alias_maps.cf
192
193 #smtpd_reject_unlisted_sender = yes
194
195 #本地域向本地域发信也需要SMTP身份验证
196
197 #smtpd_sender_restrictions =
198 # reject_sender_login_mismatch,
199 # reject_authenticated_sender_login_mismatch,
200 # reject_unauthenticated_sender_login_mismatch
201
202 #smtpd_error_sleep_time = 1s
203 #smtpd_soft_error_limit = 10
204 #smtpd_hard_error_limit = 20
205
206 smtpd_sasl_auth_enable = yes
207 smtpd_sasl_local_domain = $myhostname
208 smtpd_sasl_security_options = noanonymous
209 smtpd_sasl_application_name = smtpd
210 smtpd_banner=$myhostname ESMTP "Version not Available"
211
212 #====================SSL/TLS========================
213 smtp_use_tls = yes
214 smtpd_use_tls = yes
215 smtp_tls_note_starttls_offer = yes
216 smtpd_tls_key_file = /etc/ssl/smtpd.pem
217 smtpd_tls_cert_file = /etc/ssl/smtpd.pem
218 smtpd_tls_CAfile = /etc/ssl/smtpd.pem
219 smtpd_tls_loglevel = 1
220 smtpd_tls_received_header = yes
221 smtpd_tls_session_cache_timeout = 3600s
222 tls_random_source = dev:/dev/urandom
223
224 #=======================BCC=========================
创建 mysql_virtual_alias_maps.cf 文件:
1 cat >> /etc/postfix/mysql_virtual_alias_maps.cf << EOF
2 user = postfix
3 password = yourpassword # 修改为你的密码
4 hosts = localhost
5 dbname = postfix
6 query = SELECT goto FROM alias WHERE address='%s' AND active = 1
7 EOF
创建 mysql_virtual_domains_maps.cf 文件:
1 cat >> /etc/postfix/mysql_virtual_domains_maps.cf << EOF
2 user = postfix
3 password = yourpassword # 修改为你的密码
4 hosts = localhost
5 dbname = postfix
6 query = SELECT domain FROM domain WHERE domain='%s'
7 #optional query to use when relaying for backup MX
8 #query = SELECT domain FROM domain WHERE domain='%s' and backupmx = '0' and active = '1'
9 EOF
创建 mysql_virtual_mailbox_limit_maps.cf 文件:
1 cat >> /etc/postfix/mysql_virtual_mailbox_limit_maps.cf << EOF
2 user = postfix
3 password = yourpassword # 修改为你的密码
4 hosts = localhost
5 dbname = postfix
6 query = SELECT quota FROM mailbox WHERE username='%s'
7 EOF
创建 mysql_virtual_mailbox_maps.cf 文件:
1 cat >> /etc/postfix/mysql_virtual_mailbox_maps.cf << EOF
2 user = postfix
3 password = yourpassword # 修改为你的密码
4 hosts = localhost
5 dbname = postfix
6 query = SELECT maildir FROM mailbox WHERE username='%s' AND active = 1
7 EOF |
|