新 Postfix 伺服器不會將郵件中繼到 Office 365,狀態=延遲

新 Postfix 伺服器不會將郵件中繼到 Office 365,狀態=延遲

我正在配置一個新的 Ubuntu 伺服器(18.04 LTS)作為內部主機的郵件中繼來發送郵件,例如在裝置出現問題時發送通知電子郵件。我們使用 Office 365,因此這使我們能夠將此類訊息從內部設備和軟體傳送到我們的郵箱。我的組織多年來一直使用 Postfix 非常簡單地進行此設定。不幸的是,設置它的員工早已去世,我找不到任何有關具體細節的文檔。然而,根據我發現的一些信息,配置似乎並不需要那麼複雜。我已經在新系統上安裝了 Postfix,並嘗試將其配置為盡可能匹配現有配置。這是我的/etc/postfix/main.cf文件,進行了匿名化更改:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2

# TLS parameters
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 = myservername.domain.edu
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = myservername.domain.edu, localhost.domain.edu, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
message_size_limit = 10240000
permit_mynetworks = yes
mynetworks = 172.16.4.0/24, 172.16.5.0/24, 172.16.246.0/24, 192.168.90.0/24, 192.168.1.0/24, ###.###.103.0/24, ###.###.104.0/24, ###.###.106.0/24, ###.###.250.0/24, 10.19.64.0/27, 10.19.66.0/27, 10.19.68.0/27

我可以從這個新伺服器訪問互聯網,我可以 ping 互聯網上的資源等,但它不發送郵件。我不斷看到有關訊息被延遲和連接超時的日誌條目。這是我的文件的最後 30 行/var/log/mail.log,以便您可以看到我看到的訊息類型。我再次對內容進行了匿名處理:

user@myservername:~$ tail -30 /var/log/mail.log
May 29 14:23:49 myservername postfix/smtp[3351]: warning: /etc/postfix/main.cf, line 49: overriding earlier entry: mynetworks=127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
May 29 14:24:19 myservername postfix/smtp[3349]: connect to subdomain.domain.edu[###.###.104.118]:25: Connection timed out
May 29 14:24:19 myservername postfix/smtp[3350]: connect to mxa-00246402.gslb.pphosted.com[148.163.147.197]:25: Connection timed out
May 29 14:24:19 myservername postfix/smtp[3351]: connect to subdomain.domain.edu[###.###.104.154]:25: Connection timed out
May 29 14:24:19 myservername postfix/smtp[3351]: connect to subdomain.domain.edu[###.###.104.57]:25: Connection refused
May 29 14:24:19 myservername postfix/smtp[3351]: connect to subdomain.domain.edu[###.###.103.6]:25: Connection refused
May 29 14:24:19 myservername postfix/smtp[3351]: connect to subdomain.domain.edu[###.###.250.72]:25: Connection refused
May 29 14:24:49 myservername postfix/smtp[3350]: connect to mxb-00246402.gslb.pphosted.com[148.163.143.147]:25: Connection timed out
May 29 14:24:49 myservername postfix/smtp[3349]: connect to subdomain.domain.edu[###.###.103.43]:25: Connection timed out
May 29 14:24:49 myservername postfix/bounce[3357]: warning: /etc/postfix/main.cf, line 49: overriding earlier entry: mynetworks=127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
May 29 14:24:49 myservername postfix/smtp[3351]: connect to subdomain.domain.edu[###.###.103.43]:25: Connection timed out
May 29 14:24:49 myservername postfix/bounce[3358]: warning: /etc/postfix/main.cf, line 49: overriding earlier entry: mynetworks=127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
May 29 14:24:49 myservername postfix/smtp[3350]: 35A96120180: to=<[email protected]>, relay=none, delay=631, delays=571/0.03/60/0, dsn=4.4.1, status=deferred (connect to mxb-00246402.gslb.pphosted.com[148.163.143.147]:25: Connection timed out)
May 29 14:24:49 myservername postfix/smtp[3351]: 4047E12083C: to=<[email protected]>, relay=none, delay=431116, delays=431056/0.04/60/0, dsn=4.4.1, status=deferred (connect to subdomain.domain.edu[###.###.103.43]:25: Connection timed out)
May 29 14:25:19 myservername postfix/smtp[3349]: connect to subdomain.domain.edu[###.###.104.154]:25: Connection timed out
May 29 14:25:19 myservername postfix/smtp[3349]: 68665120733: to=<[email protected]>, relay=none, delay=434852, delays=434761/0.06/90/0, dsn=4.4.1, status=deferred (connect to subdomain.domain.edu[###.###.104.154]:25: Connection timed out)
May 29 14:25:19 myservername postfix/qmgr[1688]: 68665120733: from=<[email protected]>, status=expired, returned to sender
May 29 14:25:19 myservername postfix/cleanup[3365]: warning: /etc/postfix/main.cf, line 49: overriding earlier entry: mynetworks=127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
May 29 14:25:19 myservername postfix/cleanup[3365]: CE1B8124492: message-id=<[email protected]>
May 29 14:25:19 myservername postfix/bounce[3357]: 68665120733: sender non-delivery notification: CE1B8124492
May 29 14:25:19 myservername postfix/qmgr[1688]: CE1B8124492: from=<>, size=2844, nrcpt=1 (queue active)
May 29 14:25:19 myservername postfix/qmgr[1688]: 68665120733: removed
May 29 14:25:49 myservername postfix/smtp[3350]: connect to mxa-00246402.gslb.pphosted.com[148.163.147.197]:25: Connection timed out
May 29 14:26:19 myservername postfix/smtp[3350]: connect to mxb-00246402.gslb.pphosted.com[148.163.147.197]:25: Connection timed out
May 29 14:26:19 myservername postfix/smtp[3350]: CE1B8124492: to=<[email protected]>, relay=none, delay=60, delays=0.03/0/60/0, dsn=4.4.1, status=deferred (connect to mxb-00246402.gslb.pphosted.com[148.163.147.197]:25: Connection timed out)
May 29 14:28:49 myservername postfix/qmgr[1688]: 8F7B51200D6: from=<>, size=2838, nrcpt=1 (queue active)
May 29 14:28:49 myservername postfix/trivial-rewrite[3378]: warning: /etc/postfix/main.cf, line 49: overriding earlier entry: mynetworks=127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
May 29 14:28:49 myservername postfix/qmgr[1688]: 92033120E39: from=<>, size=2836, nrcpt=1 (queue active)
May 29 14:28:49 myservername postfix/smtp[3379]: warning: /etc/postfix/main.cf, line 49: overriding earlier entry: mynetworks=127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
May 29 14:28:49 myservername postfix/smtp[3380]: warning: /etc/postfix/main.cf, line 49: overriding earlier entry: mynetworks=127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

主機本身沒有配置或運行防火牆,根據我與網路工程師的對話,應該沒有任何東西阻止此流量。但是,從現有伺服器,我可以在連接埠 25 上遠端登入到我的組織的 MX 記錄中列出的 Office 365 郵件伺服器名稱,並獲得回應、向其拋出「helo」等。從這個新伺服器。我的網路工程師確信防火牆上沒有任何東西會阻止傳出流量,雖然他一直在嘗試幫助我解決此問題,但他沒有看到任何表明導致此問題的原因。我不確定我還會錯過什麼。任何幫助將不勝感激。

答案1

為了設定 SMTP 中繼,您必須定義中繼主機以及一些 sasl 驗證項目。

您想將這些組態項目新增到 main.cf 的末端嗎?

smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
relayhost = your.office365.relayhost
smtp_tls_security_level = may

顯然,您必須透過真實主機名稱更改“your.office365.relayhost”(應該[smtp.office365.com]:587根據此連結:https://secopsmonkey.com/mail-relaying-postfix-through-office-365.html

檔案 sasl_password 也在連結教程中進行了解釋,它應該看起來像

[smtp.office365.com]:587 [email protected]:soopersekretPassvv0rd

並且您必須使用 來對其進行後期映射postmap hash:/etc/postfix/sasl_passwd。之後,您必須使用 重新啟動 postfix systemctl restart postfix.service

我不熟悉 Office 365,但對於透過 MS Exchange Server 進行中繼,通常您必須嘗試不同的連接埠。

希望這可以幫助!

相關內容