【问题标题】:Postfix with office365 integration for sending emailsPostfix 与 office365 集成用于发送电子邮件
【发布时间】: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)

我在哪里做错了?谢谢!

【问题讨论】:

    标签: email office365 postfix


    【解决方案1】:

    首先将您的通用文件更改为:

    /.*/    email@domain.com
    

    其次验证您的通用和 sasl 权限: 设置所有者和权限。

    sudo postmap hash:/etc/postfix/generic 
    sudo chown root:root /etc/postfix/generic /etc/postfix/generic.db  
    sudo chmod 644 /etc/postfix/generic /etc/postfix/generic.db  
    

    sasl_passwddb 文件相同。

    【讨论】:

    • 嘿,谢谢你的建议。我最终不得不安装这些:yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain。不知道它们是什么,但它现在可以工作了!
    【解决方案2】:

    在新版本的 Ubuntu/Debian 上,您需要安装此软件包:libsasl2-modules

    apt install libsasl2-modules
    

    然后重新加载后缀

    systemctl reload postfix
    

    【讨论】:

    • 为了让你的答案更有用,你应该解释你在做什么以及它为什么起作用;您还可以使用格式使您的答案更具可读性。
    【解决方案3】:

    我必须安装这些...不确定它们是什么,但它们可以工作!

    yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain

    【讨论】:

      猜你喜欢
      • 2018-08-10
      • 2017-10-12
      • 1970-01-01
      • 1970-01-01
      • 2015-08-19
      • 2020-02-06
      • 2011-04-08
      • 2016-12-27
      • 2015-06-24
      相关资源
      最近更新 更多