编程语言
首页 > 编程语言> > Python imaplib登录失败

Python imaplib登录失败

作者:互联网

我正在研究邮件应用程序并遇到Python imaplib的一个大问题.

这是我尝试用来登录邮件服务器的代码.

M = imaplib.IMAP4(self.server,int(self.port))
M.login(self.user, self.password)

我正在使用“端口143”,“useSLL = false”,没有安全性.
这是我在尝试登录服务器时收到的消息.

DEBUG:root:Login failed.
Traceback (most recent call last):
  File "/opt/splunk/etc/apps/IMAPmailbox/bin/get_imap_email.py", line 347, in getMail
    M.login(self.user, self.password)
  File "/opt/splunk/lib/python2.7/imaplib.py", line 520, in login
    raise self.error(dat[-1])
error: Login failed.
None
Traceback (most recent call last):
  File "/opt/splunk/etc/apps/IMAPmailbox/bin/get_imap_email.py", line 724, in <module>
    parseArgs()
  File "/opt/splunk/etc/apps/IMAPmailbox/bin/get_imap_email.py", line 716, in parseArgs
    imapProc.getMail()
  File "/opt/splunk/etc/apps/IMAPmailbox/bin/get_imap_email.py", line 352, in getMail
    raise LoginError('Could not log into server: %s with password provided' % self.server)
__main__.LoginError: Could not log into server: (my server) with password provided

p / s:我有另一个邮件应用程序,它可以让电子邮件在ruby上抛出imap,并且它运行良好,端口143无法安全.
有人请帮我解决这个问题.谢谢

解决方法:

请改用它

M = imaplib.IMAP4_SSL(self.server,int(self.port))
 M.login(self.user,self.password)

我使用imaplib.IMAP4_SSL而不是imaplib.IMAP4这似乎对我有用

标签:python,email,imaplib
来源: https://codeday.me/bug/20190710/1427080.html