Email

為什麼 Outlook 只連接到我的伺服器而不發送任何電子郵件?

  • February 1, 2022

我從 Gmail 或我註冊的任何郵件列表接收電子郵件都沒有任何問題,但由於某種原因 Outlook 拒絕向我的郵件伺服器發送任何電子郵件。

_handle_client readline: b'EHLO NAM02-BN1-obe.outbound.protection.outlook.com\r\n'                                                                                                           │
('52.100.160.208', 55618) >> b'EHLO NAM02-BN1-obe.outbound.protection.outlook.com'                                                                                                           │
('52.100.160.208', 55618) << b'250-0.0.0.0'                                                                                                                                                  │
('52.100.160.208', 55618) << b'250-SIZE 33554432'                                                                                                                                            │
('52.100.160.208', 55618) << b'250-8BITMIME'                                                                                                                                                 │
EHLO from 'NAM02-BN1-obe.outbound.protection.outlook.com'                                                                                                                                    │
('52.100.160.208', 55618) << b'250-AUTH PLAIN\n250-MAIL\n250 HELP'   

最初我認為這可能是因為 Outlook 正在使用 TLS 進行某種惡作劇 - 但從響應中完全刪除 STARTTLS 並沒有幫助。不管有沒有 STARTTLS,Outook 都會連接到我的郵件伺服器,發出 EHLO,然後就……放棄了?我其實不知道。

但它確實告訴我一個謊言:

1/29/2022 4:39:30 PM - Server at BYAPR05MB6069.namprd05.prod.outlook.com returned '550 5.4.317 Message expired, cannot connect to remote server(451 4.4.0
Socket error SocketError)'
1/29/2022 4:27:02 PM - Server at waynewerner.com (104.236.246.170) returned '450 4.4.317 Cannot connect to remote server [Message=451 4.4.0 Socket error
SocketError] [LastAttemptedServerName=waynewerner.com] [LastAttemptedIP=104.236.246.170:25] [BN7NAM10FT066.eop-nam10.prod.protection.outlook.com](451 4.4.0
Socket error SocketError)'

我的伺服器沒有返回450 4.4.317我在日誌中可以看到的任何內容。我什至在我的伺服器原始碼中都沒有看到支持響應的任何地方。Outlook在故障郵件中提供https://docs.microsoft.com/en-us/microsoft-365/security/office-365-security/mail-flow-intelligence-in-office-365?view=o365-worldwide ,但以下資訊:

Error code: 450 4.4.317 Cannot connect to remote server

Typically, this error means Microsoft 365 connected to the destination email server, but the server responded with an immediate error, or doesn't meet the connection requirements. The error details will explain the problem. For example:

   The destination email server responded with a "Service not available" error, which indicates the server is unable to maintain communication with Microsoft 365.
   The connector is configured to require TLS, but the destination email server doesn't support TLS.

也似乎 Outlook 做錯了什麼。將其與 Google 完全合理的方法進行比較:

_handle_client readline: b'EHLO mail-vk1-f175.google.com\r\n'
('209.85.221.175', 42948) >> b'EHLO mail-vk1-f175.google.com'
('209.85.221.175', 42948) << b'250-0.0.0.0'
('209.85.221.175', 42948) << b'250-SIZE 33554432'
('209.85.221.175', 42948) << b'250-8BITMIME'
('209.85.221.175', 42948) << b'250-STARTTLS'
EHLO from 'mail-vk1-f175.google.com'
('209.85.221.175', 42948) << b'250-AUTH PLAIN\n250-STARTTLS\n250 HELP'
_handle_client readline: b'STARTTLS\r\n'
('209.85.221.175', 42948) >> b'STARTTLS'
('209.85.221.175', 42948) << b'220 Ready to start TLS'
_handle_client readline: b'EHLO mail-vk1-f175.google.com\r\n'
('209.85.221.175', 42948) >> b'EHLO mail-vk1-f175.google.com'
('209.85.221.175', 42948) << b'250-0.0.0.0'
('209.85.221.175', 42948) << b'250-SIZE 33554432'
('209.85.221.175', 42948) << b'250-8BITMIME'
('209.85.221.175', 42948) << b'250-AUTH LOGIN PLAIN'
EHLO from 'mail-vk1-f175.google.com'
('209.85.221.175', 42948) << b'250-AUTH PLAIN\n250-STARTTLS\n250-MAIL\n250 HELP'
_handle_client readline: b'MAIL FROM:<me@gmail.com> SIZE=3159\r\n'

在這裡,我們看到 Gmail:

  • EHLO
  • 獲取響應,包括 STARTTLS
  • STARTTLS 的
  • 開始發送郵件

與 Outlook 相比:

  • EHLO
  • 沒有其他的

我什至仔細檢查過,看起來 Outlook 之後甚至沒有再發送一個字節的數據。

幾分鐘後,連接看起來會超時,等待 Outlook 發送數據:

[2022-01-31 18:04:54,355][mail.log][INFO] ('40.107.93.71', 64992) >> b'EHLO NAM10-DM6-obe.outbound.protection.outlook.com'
[2022-01-31 18:04:54,356][mail.log][DEBUG] ('40.107.93.71', 64992) << b'250-0.0.0.0'
[2022-01-31 18:04:54,356][mail.log][DEBUG] ('40.107.93.71', 64992) << b'250-SIZE 33554432'
[2022-01-31 18:04:54,357][mail.log][DEBUG] ('40.107.93.71', 64992) << b'250-8BITMIME'
[2022-01-31 18:04:54,358][mail.log][DEBUG] ('40.107.93.71', 64992) << b'250-STARTTLS'
[2022-01-31 18:04:54,359][mail.log][DEBUG] ('40.107.93.71', 64992) << b'250-AUTH PLAIN\n250-MAIL\n250 HELP'
[2022-01-31 18:04:54,359][mail.log][DEBUG] ('40.107.93.71', 64992) reading data...
[2022-01-31 18:04:54,360][mail.log][DEBUG] ('40.107.93.71', 64992) peeking
[2022-01-31 18:09:54,356][mail.log][INFO] ('40.107.93.71', 64992) connection timeout
[2022-01-31 18:09:54,358][mail.log][INFO] ('40.107.93.71', 64992) connection lost

任何線索我沒有提供的 Outlook 可能在這裡尋找什麼?

好吧,事實證明,答案一直擺在我面前:

('209.85.221.175', 42948) << b'250-AUTH PLAIN\n250-STARTTLS\n250 HELP'

Outlook在響應位之間嚴格執行。'\r\n'

這解決了我的問題

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