我正在使用 python3、aiosmtpd 从私有局域网上的 dvr 捕获电子邮件并剥离附件。我已经为 aiosmtp 和一些测试 python 编写了一个处理程序来发送一封带有附件、纯文本、没有加密的电子邮件,并且它可以工作。当 dvr 发送电子邮件时,它会导致连接丢失。
我尝试使用以下方法进行调试:
python3 -m aiosmtpd -d -n -l 192.168.66.1:11125
添加“--no-requiretls”似乎不会改变结果。
- 项目清单
这是结果:
2021-06-07 21:29:30 - Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin)
Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin)
2021-06-07 21:29:30 - Peer: ('192.168.66.99', 47054)
Peer: ('192.168.66.99', 47054)
2021-06-07 21:29:30 - ('192.168.66.99', 47054) handling connection
('192.168.66.99', 47054) handling connection
2021-06-07 21:29:30 - ('192.168.66.99', 47054) >> b'EHLO 192.168.66.1'
('192.168.66.99', 47054) >> b'EHLO 192.168.66.1'
2021-06-07 21:29:31 - ('192.168.66.99', 47054) >> b'AUTH LOGIN'
('192.168.66.99', 47054) >> b'AUTH LOGIN'
2021-06-07 21:29:31 - ('192.168.66.99', 47054) connection lost
('192.168.66.99', 47054) connection lost
2021-06-07 21:29:31 - ('192.168.66.99', 47054) Connection lost during _handle_client()
('192.168.66.99', 47054) Connection lost during _handle_client()
smtp.py,由 pip3 安装的 aiosmtpd 1.4.2 的一部分:
def __init__(
...
auth_require_tls=True,...)
...
self._auth_require_tls = auth_require_tls
async def smtp_AUTH(self, arg: str) -> None:
...
elif self._auth_require_tls and not self._tls_protocol:
return await self.push("538 5.7.11 Encryption required for requested authentication mechanism")
因此,如果收到 AUTH,上述默认值将失败,因为 init,如果未由用户代码设置,则将 _auth_require_tls 保留为 True。由于在这种情况下 AUTH 很简单,因此协议不会是 tls。
再调试一下,我发现客户端没有响应挑战。
INFO:mail.log:('192.168.66.99', 47054) << challenge: b'334 VXNlciBOYW1lAA=='
不知道现在该尝试什么。有什么建议么?