Pergunta

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?

Foi útil?

Solução 2

I realized I needed to do IMAP4_SSL() - has to be SSL for IMAP and for using IMAP I need the IMAP server for gmail which is imap.googlemail.com. I ultimately got it work without specifying a port. So, final code is:

M = imaplib.IMAP4_SSL('imap.googlemail.com')

Outras dicas

You are connecting to the wrong port. 587 is authenticated SMTP, not IMAP; the IMAP designated port number is 143 (or 993 for IMAPS).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top