Read gmail email using python imap

import imaplib
 
mailserver = imaplib.IMAP4_SSL('imap.gmail.com', 993)
username = 'gmailusername'
password = 'gmailpassword'
mailserver.login(username, password)
 
status, count = mailserver.select('Inbox')
status, data = mailserver.fetch(count[0], '(UID BODY[TEXT])')
 
print data[0][1]
 
mailserver.close()
mailserver.logout()

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.