带有Dovecot / SSL的Python的smtplib
作者:互联网
我正在尝试使用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 …”.
解决方法:
Dovecot是POP3 / IMAP服务器(用于检查邮件). smtplib是SMTP客户端(用于发送邮件).要连接到Dovecot,您需要使用imaplib或poplib之类的东西.
标签:smtplib,ssl,smtp,dovecot,python 来源: https://codeday.me/bug/20191201/2079471.html