Open ajaynair opened 5 years ago
Hmm, this is basically reading emails in the account - bad for privacy! Maybe there is a way to 'test' email delivery to a recipient's mailbox, similar to traceroute?
A more acceptable privacy-aware method could be to have the user manually forward all 'bounced' emails to a WittyMail email address, which we can then read and process separately. Ties in to session management.
Can we use this? import poplib from email import parser
breaks with if this is left out for some reason (MAXLINE is set too low by default.)
poplib._MAXLINE=20480
pop_conn = poplib.POP3_SSL('your pop server',port) pop_conn.user(username) popconn.pass(password)
Get messages from server:
messages = [pop_conn.retr(i) for i in range(1, len(pop_conn.list()[1]) + 1)]
Concat message pieces:
messages = ["\n".join(mssg[1]) for mssg in messages]
Parse message intom an email object:
messages = [parser.Parser().parsestr(mssg) for mssg in messages] for message in messages: if "Undeliverable" in message['subject']: