为了解决网站通过smtp服务完成发送邮件api功能,需要配置 多个ssl支持,否则无法完成发信操作
出现:
SMTP Error: Could not connect to SMTP host. Connection failed. stream_socket_enable_crypto(): Peer certificate CN=`m.cwbio.com.cn' did not match expected CN=`smtp.cwbio.com.cn'
下面以:m.cwbio.com.cn, smtp.cwbio.com.cn 为例说明
#
# TLS settings.
#
# SSL key, certificate, CA
#
#smtpd_tls_key_file = /etc/ssl/private/iRedMail.key
#smtpd_tls_cert_file = /etc/ssl/certs/iRedMail.crt
smtpd_tls_CAfile = /etc/ssl/certs/iRedMail.crt
smtpd_tls_CApath = /etc/ssl/certs
# provide the primary certificate for the server, to be used for outgoing connections
smtpd_tls_chain_files =
/etc/ssl/private/iRedMail.key,
/etc/ssl/certs/iRedMail.crt
# provide the map to be used when SNI support is enabled
tls_server_sni_maps = hash:/etc/postfix/vmail_ssl.map
# Compile with postmap -F hash:/etc/postfix/vmail_ssl.map when updating
# One host per line
m.cwbio.com.cn /etc/ssl/private/iRedMail.key /etc/ssl/certs/iRedMail.crt
smtp.cwbio.com.cn /etc/ssl/smtp.cwbio.com.cn.key /etc/ssl/smtp.cwbio.com.cn.pem
# add more domains with keys and certs as needed
# postmap -F hash:/etc/postfix/vmail_ssl.map
# openssl s_client -connect smtp.cwbio.com.cn:587 -servername smtp.cwbio.com.cn -starttls smtp
# openssl s_client -connect m.cwbio.com.cn:587 -servername m.cwbio.com.cn -starttls smtp
#systemctl restart postfix