how do i read mails from my mail box using python??
import getpass, imaplib
M = imaplib.IMAP4( IMAP4.gmail.com:993 )
M.login(getpass.getuser(), getpass.getpass())
M.select()
typ, data = M.search(None, ALL )
for num in data[0].split():
typ, data = M.fetch(num, (RFC822) )
print Message %s
%s
% (num, data[0][1])
M.close()
M.logout()
this is my code.. but when i execute this its throwing error:
Traceback (most recent call last):
File "E:/jagdish/python progs/readmail.py", line 2, in <module>
M = imaplib.IMAP4( IMAP4.gmail.com:993 )
File "C:Python25libimaplib.py", line 163, in __init__
self.open(host, port)
File "C:Python25libimaplib.py", line 230, in open
self.sock.connect((host, port))
File "<string>", line 1, in connect
gaierror: (11001, getaddrinfo failed )
can anyone help me with this???