在/etc/postfix/main.cf中添加如下資訊
smtpd_tls_cert_file=/etc/ssl/certs/your.crt
smtpd_tls_key_file=/etc/ssl/private/your.key
smtpd_tls_CAfile=/etc/ssl/certs/your-chaint.crt
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
relayhost = [smtp.exmail.qq.com]:587
smtp_sasl_auth_enable = yes
smtpd_tls_auth_only = no
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
#smtp_generic_maps = hash:/etc/postfix/generic
在/etc/postfix/建立檔案sasl_passwd,填寫如下内容
[smtp.exmail.qq.com]:587 EMAIL-ADDRESS:PASSWORD
然後通過如下指令生成hash庫
postmap /etc/postfix/sasl_passwd
重新開機postfix
service postfix restart
測試一下
echo 'Hello Test' | mail -s "a new subject" [email protected] -a "Content-Type: text/plain; charset=UTF-8" -aFrom:[email protected]
在配置過程中,有一個問題是
Oct 17 13:24:17 iZ23i21c87bZ postfix/smtp[11462]: DA1F842BA1: to=<[email protected]>, relay=smtp.exmail.qq.com[163.177.90.125]:587, delay=4
66, delays=466/0.01/0.29/0, dsn=4.0.0, status=deferred (SASL authentication failed; server smtp.exmail.qq.com[163.177.90.125] said: 530 Must is
sue a STARTTLS command first.)
這個原因可能是如下原因的一個。在main.cf裡面添加了如下的實作了。也就是說不僅需要在main.cf裡面追加key和cert,還需要追加chain cert
smtpd_tls_auth_only = no
<pre name="code" class="html">smtpd_tls_CAfile=/etc/ssl/certs/your-chaint.crt