I have the following line of code using imaplib
M = imaplib.IMAP4('smtp.gmail.com', 587)
I get the following error from imaplib:
abort: unexpected response: '220 mx.google.com ESMTP o13sm12303588vde.21'
However from reading elsewhere, it seems that that response is the correct response demonstrating that the connection was made to the server successfully at that port.
Why is imaplib giving this error?
You are connecting to the wrong port. 587 is authenticated SMTP, not IMAP; the IMAP designated port number is 143 (or 993 for IMAPS).
python imaplib unexpected response 220