yum install postfix system-switch-mail
vi /etc/postfix/main.cf
myhostname = mail.example.com
myorigin = $myhostname
myorigin = example.com
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = 192.168.1.0/24, 127.0.0.0/8
relay_domains = $mydestination
設定開機自啟:
echo "/usr/sbin/postfix start" >> /etc/rc.d/rc.local
yum -y install dovecot
cp /etc/dovecot.conf /etc/dovecot.conf.bak
vi /etc/dovecot.conf
protocols = pop3
ssl_disable = yes
信箱儲存位置:
vi /etc/dovecot/conf.d/10-mail.conf
mail_location = mbox:~/mail:INBOX=/var/mail/%u
認證設定:
vi /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no
auth_mechanisms = plain login
service dovecot restart
chkconfig dovecot on
vi /etc/postfix/main.cf
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
chkconfig saslauthd on
service saslauthd restart
yum -y install clamav amavisd-new
service clamd start
chkconfig --level 3,5 freshclam on
service amavisd start
chkconfig --level 3,5 amavisd on
指定郵件域:
vi /etc/amavisd/amavisd.conf
$mydomain = 'example.com';
vi /etc/postfix/master.cf
# 定義 amavis 服務
amavis unix - - - - 2 smtp
-o smtp_data_done_timeout=1200
# 接收掃描後郵件的專用 SMTP 埠
127.0.0.1:10025 inet n - n - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
並在 main.cf 指定:
content_filter = smtp:127.0.0.1:10024
/var/log/maillog 確認 Passed CLEAN 或 Blocked SPAM。參考文章 Postfix 部署多個 Content Filter 方法,可將 MailGate、Altermime 等串接於 Amavisd 之前或之後。