Python imaplib登录失败

时间:2017-09-07 07:13:14

标签: python email imaplib

我正在处理邮件应用程序并遇到Python imaplib的一个大问题。

以下是我尝试用来登录邮件服务器的代码。

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

我正在使用"port 143""useSLL = false"no secure
这是我在尝试登录服务器时收到的消息。

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无法安全。

有人请帮我解决这个问题。感谢

1 个答案:

答案 0 :(得分:0)

改为使用

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

我使用imaplib.IMAP4_SSL代替imaplib.IMAP4,这似乎对我有用