【发布时间】:2017-03-26 16:54:01
【问题描述】:
我有一个将部署到客户站点的 CentOS7 服务器。当服务器出现问题时,我想通过电子邮件收到警报。
我有一个 office365 帐户,所以我正在考虑是否可以将其用作 SMTP 中继服务器。 (如果我的话没有意义,请在此原谅我,因为我对 SMTP 和电子邮件相关技术的了解非常有限)。
我的第一个问题是,我需要对 office365 帐户做些什么特别的事情吗?我使用 smtp.office365.com:587 作为 SMTP 中继主机。
这是我的后缀 main.cf 配置:
relayhost = [smtp.office365.com]:587
smtp_always_send_ehlo = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_generic_maps = hash:/etc/postfix/generic
smtp_tls_security_level = may
smtp_sasl_security_options = noanonymous
这是我的“通用”和“sasl_passwd”文件的样子。我还使用“postmap”来生成 .db 文件
/.*/ <o365 email>
root@server.difan.local <o365 email>
root@localdomain <o365 email>
@localdomain <o365 email>
[smtp.office365.com]:587 <o365 email>:<o365 password>
这是我用来测试的命令
echo "This is the body of the email" | mail -s "This is the subject line" difan.zhao@outlook.com
这是我在 /var/log/maillog 中看到的内容
Mar 26 10:46:00 server postfix/pickup[1921]: 5DC594087202: uid=0 from=<root>
Mar 26 10:46:00 server postfix/cleanup[2495]: 5DC594087202: message-id=<20170326164600.5DC594087202@server.difan.local>
Mar 26 10:46:00 server postfix/qmgr[1922]: 5DC594087202: from=<root@server.difan.local>, size=486, nrcpt=1 (queue active)
Mar 26 10:46:00 server postfix/smtp[2497]: warning: SASL authentication failure: No worthy mechs found
Mar 26 10:46:00 server postfix/smtp[2497]: 5DC594087202: SASL authentication failed; cannot authenticate to server smtp.office365.com[40.97.128.34]: no mechanism available
... <last two messages repeated 4 times>
Mar 26 10:46:02 server postfix/smtp[2497]: 5DC594087202: to=<difan.zhao@outlook.com>, relay=smtp.office365.com[40.97.142.194]:587, delay=2.2, delays=0.02/0/2.2/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.office365.com[40.97.142.194]: no mechanism available)
我在哪里做错了?谢谢!
【问题讨论】: