Python 3 IMAPClient object error

934 Views Asked by At

I try to call the imapclient.IMAPClient() function to create an IMAPClient object.

Code is like that:

import imapclient
imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)

print('Enter your mail adress')
mail = input()

print('Enter your password')
password = input()

imapObj.login(' mail ', ' password ')

Error:

Traceback (most recent call last):
  File "C:\Users\Purgoufr\Documents\Eclipse Projects\Python\Email_and_Text_Message\IMAP_basic_codes.py", line 21, in <module>
    imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)
  File "C:\Users\Purgoufr\AppData\Local\Programs\Python\Python35-32\Lib\imapclient\imapclient.py", line 152, in __init__
    self._imap = self._create_IMAP4()
  File "C:\Users\Purgoufr\AppData\Local\Programs\Python\Python35-32\Lib\imapclient\imapclient.py", line 164, in _create_IMAP4
    self._timeout)
  File "C:\Users\Purgoufr\AppData\Local\Programs\Python\Python35-32\Lib\imapclient\tls.py", line 209, in __init__
    imaplib.IMAP4.__init__(self, host, port)
  File "C:\Users\Purgoufr\AppData\Local\Programs\Python\Python35-32\Lib\imaplib.py", line 189, in __init__
    self.open(host, port)
  File "C:\Users\Purgoufr\AppData\Local\Programs\Python\Python35-32\Lib\imapclient\tls.py", line 215, in open
    self.sock = wrap_socket(sock, self.ssl_context, host)
  File "C:\Users\Purgoufr\AppData\Local\Programs\Python\Python35-32\Lib\imapclient\tls.py", line 34, in <lambda>
    context.wrap_socket(sock, server_hostname = host)
AttributeError: 'NoneType' object has no attribute 'wrap_socket'
1

There are 1 best solutions below

0
On BEST ANSWER

I found the solution. Delete codes below:

print('Enter your mail adress')
mail = input()

print('Enter your password')
password = input()

imapObj.login(' mail ', ' password ')

Write the following code:

print('Enter your mail adress')
mail = input()
print(mail)

print('Enter your password')
password = input()
print(password)
imapObj.login(mail, password)