i use pop3 which "marks" emails as read after a successful grab and popconn.quit.
apparently it doesnt make a mark that can be seen but is aware of emails already read.
you could also delete the messages which have been read..
Code: Select all
from email import parser
frm = "your_email"
password = "your_password"
pop_conn = poplib.POP3_SSL('pop.gmail.com')
print 'dialled in'
print 'checking mail'
pop_conn = mail_connection()
messages = [pop_conn.retr(i) for i in range(1, len(pop_conn.list()) + 1)]
messages = ["\n".join(mssg) for mssg in messages]
messages = [parser.Parser().parsestr(mssg) for mssg in messages]
if delete_after == True:
delete_messages = [pop_conn.dele(i) for i in range(1, len(pop_conn.list()) + 1)]
messages = fetch_mail()
attachments = 
for message in messages:
if message['subject'] == 'email_your_looking_for':
i used to have do_stuff before the pop_conn.quit but any error in my do_stuff caused the email to NOT be "marked as read" as the pop_conn.quit was never reached.. this way seems to work better... though im just about to post on here as im having some issues downloading from my emails.. works sometimes not others.