I’m trying to write a script that logs into my email server(yahoo) and checks for messages from a certain sender. This is my first time useing the IMAP module and I can’t seem to get it to work. Right now I have only a few lines of code.
from imaplib import *
server = IMAP4_SSL('mail.yahoo.com')
server.login('myusername','mypassword')
mail_folders = server.list()
for folders in mail_folders:
print(folders)
at this point all I’m trying to do is login to the mail server and retrieve a list of folders. However I never get connected. the interpreter throws a
[Errno 10060] A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because connected host
has failed to respond
I’m not sure if this has something to do with SSL or what. I have managed to get a connection with httplib.HTTPSConnection, But I would rather use IMAP then webscrape.
I think the problem is just the server name that is wrong. Replacing
'mail.yahoo.com'with'imap.mail.yahoo.com'worked for me.