我已经为 mandrill 配置了 postfix,如下所示
在 /etc/postfix/sasl_passwd 中
[smtp.mandrillapp.com]:587 myusername:apikey
然后跑了postmap /etc/postfix/sasl_passwd
我/etc/postfix/main.cf
添加了
myhostname = webmail.mysite.com
mydestination = localhost
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
relayhost = [smtp.mandrillapp.com]:587
但是邮件发送失败日志显示
SASL authentication failed; server smtp.mandrillapp.com[52.7.100.156] said: 435 4.7.8 Error: authentication failed:
答案1
我正在使用 centos 7 终于可以正常工作了!我遇到了这个问题( tail -f /var/log/mailog
):
to=<[email protected]>, relay=smtp.sendgrid.net[169.45.113.201]:587, delay=0.3, delays=0.05/0.07/0.16/0.02, dsn=5.0.0, status=bounced (host smtp.sendgrid.net[169.45.113.201] said: 550 Unauthenticated senders not allowed (in reply to MAIL FROM command))
然后我以这种方式更改文件/etc/postfix/main.cf
,将以下行添加到文件末尾
mtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
mailbox_size_limit = 256000000
# Sendgrid Settings
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:apikey:SG.YOUR_SENDGRID_KEY
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587
然后使用以下命令安装 postfix 缺少的模块依赖项:
sudo yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain
然后重新启动 postfix
sudo systemctl restart postfix.service
答案2
在你的smtp_sasl_password_maps
地图中,关键应该是仅有的主机名,不带括号或端口号。
smtp.mandrillapp.com [email protected]:Y1gkQRajCjusxkvEXwv1Z