Python login error imaplib

I am working on a mail application and am facing a big problem with Python imaplib.

Here is the code I'm trying to use to log in to the mail server.

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

I use the "port 143", "useSLL = false", no secure.
And here is the message that I get when I try to login to the server.

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: I have another email application that receives email, throws imap on ruby ​​and works fine with port 143 without protection.

Someone please help me solve this problem. Thanks

+4
source share
1 answer

Use this instead

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

imaplib.IMAP4_SSL imaplib.IMAP4, , ,

0

Source: https://habr.com/ru/post/1685212/


All Articles