Postfix 是常見的郵件傳輸代理程式。若要讓主機具備基本的郵件發送能力,可先完成安裝,再設定主設定檔與 SMTP 認證。
rpm -qa postfix yum install postfix
vim /etc/postfix/main.cf
主要設定範例:
myhostname = smtp.rhttp.cn mydomain = rhttp.com myorigin = $mydomain inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain relay_domains = $mydestination mynetworks = 168.100.189.0/28, 127.0.0.0/8 home_mailbox = Maildir/ smtpd_banner = $myhostname ESMTP unknown
在設定檔尾端加入 SMTP 認證與限制:
smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_sasl_security_options = noanonymous smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination message_size_limit = 15728640
編輯 SASL 設定:
vim /usr/sasl2/smtpd.conf pwcheck_method: auxprop
編輯 saslauthd 設定:
vim /etc/sysconfig/saslauthd #MECH=shadow FLAGS=sasldb
saslpasswd2 -u smtp.rhttp.cn -c reage
完成後重新啟動 Postfix 與相關服務,即可進行基本郵件發送測試。