如何在Ubuntu上configurationpostfix以使用TLS通过Office 365(SMTP)中继邮件

我试图设置一个postfix中继到我们的networking上的一些内部设备的新的Office365设置,需要这个特定的设置。 我已经尝试了各种网站的configuration和疑难解答提示在两天的更好的一部分,但我一直运行在/etc/log/mail.log当我尝试使用发送邮件用户@ domain.com任何帮助将不胜感激。

Jun 19 05:41:16 smtphost postfix/smtp[1357]: warning: smtp.office365.com[157.56.96.22]:587 offered null AUTH mechanism list Jun 19 05:41:17 smtphost postfix/smtp[1357]: warning: SASL authentication failure: No worthy mechs found Jun 19 05:41:17 smtphost postfix/smtp[1357]: 5E7A32034A: to=<[email protected]>, relay=smtp.office365.com[157.56.96.22]:587, delay=7289, delays=7283/0.32/5.6/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.office365.com[157.56.96.22]: no mechanism available) 

这是我postconf -n的输出

 alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases append_dot_mydomain = no biff = no config_directory = /etc/postfix inet_interfaces = loopback-only inet_protocols = ipv4 mailbox_size_limit = 0 mydestination = smtphost, localhost.localdomain, localhost myhostname = smtphost mynetworks = 127.0.0.0/8 myorigin = /etc/mailname readme_directory = no recipient_delimiter = + 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_sasl_security_options = noanonymous, noplaintext smtp_tls_CAfile = /etc/postfix/cacert.pem smtp_tls_security_level = may smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) smtpd_sasl_auth_enable = yes smtpd_sasl_path = smtpd smtpd_sasl_type = dovecot smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtpd_use_tls = yes 

这里是我的sasl_passwd文件的内容:

 smtp.office365.com [email protected]:p@ssword 

我有一个类似的问题,并使用“smtp_tls_security_level = encrypt”来解决。

根据这个MS知识库文章您需要一个后缀2.9或更高版本中继工作。

我最终从源码安装了postfix-2.10.1以及cyrus-sasl-2.1.25(不像你在安装中似乎使用的是dovecoat)。因为我的发行版在它的版本库中有一个旧的postfix版本。

在这里和这里使用下面的make标志取自postfix文档

make makefiles CCARGS =“ – DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DUSE_TLS -I / usr / local / include / sasl -I / usr / local / include”AUXLIBS =“-lsasl2 -lssl -lcrypto”

我仍然在我的postfix邮件日志中收到消息“提供了空的AUTH机制列表”。 但邮件正确传送。

注意:使用与帐户电子邮件地址(或别名)不同的电子邮件地址将被Microsoft邮件服务器拒绝。

但是,您可以将FROM:字段更改为任何您喜欢的字段。 如果你find解决办法,请留下评论。

你需要确保你已经安装了SASLauthentication机制:

 yum install cyrus-sasl-plain cyrus-sasl-scram cyrus-sasl-md5 cyrus-sasl-ntlm