Postfix

Office 365 中繼訪問被拒絕(響應 RCPT TO 命令)

  • July 20, 2017

我已將後綴配置為開放中繼,以將郵件推送到 Office 365 SMTP 連接器。連接器配置為靜態 IP 地址身份驗證,工作正常。

當我嘗試使用 telnet 發送郵件時,Office365 退回: host smtp.office365.com[40.101.125.210] said: 550 Relay access denied (in reply to RCPT TO command)

我是否需要在 O365 中設置特殊權限才能允許從連接器發送郵件?會不會有不允許這樣做的規則?我不是 O365/Exchange 方面的專家…

我還測試了同一域 (mydomain.com) 和不同 FROM 地址上的其他收件人。該域列在 O365 線上交換界面的“接受域”(mydomain.com - 授權)下,遠端域中只有一個條目(預設 * = 允許所有遠端域)。

編輯: main.cf 現在有正確的中繼地址(relayhost 選項)。問題仍然存在。

以下是來自我的 SMTP 中繼的更多詳細資訊:

/var/log/mail.log:

Jul 20 10:31:11 smtp postfix[4704]: Postfix is running with backwards-compatible default settings
Jul 20 10:31:11 smtp postfix[4704]: See http://www.postfix.org/COMPATIBILITY_README.html for details
Jul 20 10:31:11 smtp postfix[4704]: To disable backwards compatibility use "postconf compatibility_level=2" and "postfix reload"
Jul 20 10:31:12 smtp postfix/master[4741]: daemon started -- version 3.1.0, configuration /etc/postfix
Jul 20 10:31:18 smtp postfix/smtpd[4745]: connect from unknown[192.168.1.25]
Jul 20 10:31:49 smtp postfix/smtpd[4745]: 04D8E2E061E: client=unknown[192.168.1.25]
Jul 20 10:32:05 smtp postfix/cleanup[4749]: 04D8E2E061E: message-id=<20170720083149.04D8E2E061E@smtp>
Jul 20 10:32:05 smtp postfix/qmgr[4743]: 04D8E2E061E: from=<info@mydomain.com>, size=328, nrcpt=1 (queue active)
Jul 20 10:32:05 smtp postfix/smtp[4750]: 04D8E2E061E: to=<me@otherdomain.com>, relay=smtp.office365.com[40.101.125.210]:25, delay=29, delays=29/0.01/0.12/0.01, dsn=5.0.0, status=bounced (host smtp.office365.com[40.101.125.210] said: 550 Relay access denied (in reply to RCPT TO command))
Jul 20 10:32:05 smtp postfix/cleanup[4749]: 641272E0635: message-id=<20170720083205.641272E0635@smtp>
Jul 20 10:32:05 smtp postfix/qmgr[4743]: 641272E0635: from=<>, size=2145, nrcpt=1 (queue active)
Jul 20 10:32:05 smtp postfix/bounce[4751]: 04D8E2E061E: sender non-delivery notification: 641272E0635
Jul 20 10:32:05 smtp postfix/qmgr[4743]: 04D8E2E061E: removed
Jul 20 10:32:05 smtp postfix/smtp[4750]: 641272E0635: to=<info@mydomain.com>, relay=smtp.office365.com[40.101.61.114]:25, delay=0.01, delays=0/0/0/0, dsn=5.0.0, status=bounced (host smtp.office365.com[40.101.61.114] said: 550 Relay access denied (in reply to RCPT TO command))
Jul 20 10:32:05 smtp postfix/qmgr[4743]: 641272E0635: removed
Jul 20 10:32:09 smtp postfix/smtpd[4745]: disconnect from unknown[192.168.1.25] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5

我的遠端登錄輸入:

root@smtp:/etc/postfix# telnet 192.168.1.25 25
Trying 192.168.1.25...
Connected to 192.168.1.25.
Escape character is '^]'.
220 smtp ESMTP Postfix (Ubuntu)
EHLO localhost
250-smtp
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
MAIL FROM: info@mydomain.com
250 2.1.0 Ok
RCPT TO: me@otherdomain.com
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: Testmail
Test

.
250 2.0.0 Ok: queued as 921452E061E
QUIT
221 2.0.0 Bye
Connection closed by foreign host.

postconf -n

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
inet_interfaces = 192.168.1.25
inet_protocols = ipv4
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = www.mydomain.com, $myhostname, smtp, localhost.localdomain, localhost
myhostname = smtp
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.1.0/24
myorigin = /etc/mailname    #mydomain.com
readme_directory = no
recipient_delimiter = +
relay_domains = static:ALL
relay_transport = relay
relayhost = smtp.office365.com
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
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

您連接到錯誤的主機以嘗試傳遞電子郵件。

您連接的主機與您域的 MX 記錄中列出的主機相同。它通常看起來像:your-domain.mail.protection.outlook.com

以下是有關如何設置通過 Office 365 進行中繼的資訊:https: //support.office.com/en-us/article/How-to-set-up-a-multifunction-device-or-application-to-send-電子郵件使用-Office-365-69f58e99-c550-4274-ad18-c805d654b4c4

引用自:https://serverfault.com/questions/863208