I'm writing a program to read emails from python

when I execute below code it hangs in the last line

import imaplib
mail_server = ""
connection = imaplib.IMAP4_SSL(mail_server,993)

I have already opened port 993.

is any other port permissions are required for imap connection to work?

1 Answer 1


Once you have connected to IMAP you will need login credentials. There are a variety of formats that could be required depending on the configuration of the IMAP server. Opening a connection to an IMAP server gives you very little functionality until you have logged in as the desired user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.