我已经在 postfix 中配置了 Ms office 365。但在发送电子邮件时遇到错误。以下是日志。
AD0C147573: lost connection with smtp.office365.com[40.97.188.242] while sending RCPT TO
Oct 30 ipostfix/cleanup[28332]: B3998475A6: message-id=<20181031080058.B3998475A6@localhost>
Oct 30 postfix/bounce[28330]: AD0C147573: sender non-delivery notification: B3998475A6
to=<[email protected]>, relay=smtp.office365.com[40.97.188.242]:587, delay=5, delays=0/0/0.02/5, dsn=5.7.57, status=bounced (host smtp.office365.com[40.97.188.242] said: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [0PR0102CA0006.prod.exchangelabs.com] (in reply to MAIL FROM command)
postconf -n 的输出
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
inet_protocols = ipv4
mydestination = ip-10-0-0-10, localhost, localhost.localdomain, , localhost
myhostname = localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 ip-10-0-0-139
readme_directory = no
recipient_delimiter = +
relayhost = [smtp.office365.com]:587
sender_canonical_maps = regexp:/etc/postfix/sender_canonical
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = encrypt
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
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
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
在 ubuntu 16 服务器中运行的 Postfix 也创建了 MX 和 TXT 记录。
编辑:Postfix 配置文件
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = ip-10-0-0-10
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = ip-10-0-0-10, localhost.localdomain, , localhost
relayhost =[smtp.office365.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtp_tls_security_level = encrypt
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
我正在使用邮件发送电子邮件。
echo "Test Message" | mail -s "Test Subject" [email protected]
答案1
错误信息显示:
客户端未通过身份验证,无法在 MAIL FROM 期间发送匿名邮件
这意味着接收邮件主机(office365)不允许“邮件发件人”地址使用中继服务器。首先检查 SASL 用户名和密码是否正确。检查
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
中所述的其他要求
https://support.office.com/en-us/article/How-to-set-up-a-multifunction-device-or-application-to-send-email-using-Office-365-69f58e99-c550-4274-ad18-c805d654b4c4
- 用户名/电子邮件地址和密码 输入正在使用的托管邮箱的登录凭据
- 验证:您必须能够配置用户名和密码才能在设备上发送电子邮件。
- 邮箱:您必须拥有获得许可的 Office 365 邮箱才能发送电子邮件。
答案2
在 main.cf 中,您可能需要设置参数 smtp_pix_workarounds =
Pix 的解决方案之一是禁用 EHLO。
disable_esmtp 禁用所有扩展 SMTP 命令:发送 HELO 而不是 EHLO。
此功能在 Postfix 2.4 及更高版本中可用。默认设置向后兼容早期版本的 Postfix。