我从 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:<[email protected]> 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 可能在这里寻找什么?
好吧,事实证明,答案一直摆在我面前:
Outlook在响应位之间严格执行。
'\r\n'
这解决了我的问题