我正在尝试使用 Python 的 smtplib 连接到 Dovecot 服务器。两者看起来都很有能力,但我一定错过了一些基本的东西。在任何一个文档中都找不到任何内容。
非 SSL 连接立即被拒绝...
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
>>> import smtplib
>>> x = smtplib.SMTP()
>>> x.set_debuglevel(True)
>>> x.connect('mail.jc-bell.com', 995)
connect: ('mail.jc-bell.com', 995)
connect: (995, 'mail.jc-bell.com')
SSL 连接似乎很接近,但 Dovecot 期待 ehlo/helo 之外的其他东西
>>> import smtplib
>>> x = smtplib.SMTP_SSL()
>>> x.set_debuglevel(True)
>>> x.connect('mail.TheMailServer.com', 995)
connect: ('mail.TheMailServer.com', 995)
connect: ('mail.TheMailServer.com', 995)
reply: '+OK Dovecot ready.\r\n'
reply: retcode (-1); Msg: Dovecot ready.
connect: Dovecot ready.
(-1, 'Dovecot ready.')
>>> x.login('me@TheMailServer.com', '...')
send: 'ehlo my.host\r\n'
reply: '-ERR Unknown command.\r\n'
reply: retcode (-1); Msg: Unknown command.
send: 'helo my.host\r\n'
reply: '-ERR Unknown command.\r\n'
reply: retcode (-1); Msg: Unknown command.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Software\Python27\lib\smtplib.py", line 564, in login
self.ehlo_or_helo_if_needed()
File "C:\Software\Python27\lib\smtplib.py", line 527, in ehlo_or_helo_if_needed
raise SMTPHeloError(code, resp)
smtplib.SMTPHeloError: (-1, 'Unknown command.')
我错过了什么?
服务器的证书是自签名的,但我认为这不是 CA 问题,因为我已经达到了“+ OK ...”。