def test_mail_to_you_is_bouncing(): msg = MailRequest("fakepeer", None, None, open("tests/bounce.msg").read()) assert msg.is_bounce() bounce_rep = bounce.mail_to_you_is_bouncing(msg) assert bounce_rep assert_equal(bounce_rep['to'], msg.bounce.final_recipient)
def test_mail_to_you_is_bouncing(): msg = MailRequest("fakepeer", None, None, open("tests/bounce.msg").read()) assert msg.is_bounce() bounce_rep = bounce.mail_to_you_is_bouncing(msg) assert bounce_rep assert_equal(bounce_rep["to"], msg.bounce.final_recipient)
def create_bounce(To, From): msg = MailRequest("fakepeer", From, To, open("tests/bounce.msg").read()) assert msg.is_bounce() msg.bounce.final_recipient = From msg.bounce.headers['Final-Recipient'] = From msg.bounce.original['from'] = From msg.bounce.original['to'] = To msg.bounce.original.To = set([To]) msg.bounce.original.From = From return msg
raise Exception("IDLE not handled? : %s" % response) def done(connection): connection.send("DONE\r\n") connection.loop = False imaplib.IMAP4.idle = idle imaplib.IMAP4.done = done if __name__ == '__main__': import os from lamson.mail import MailRequest user = os.environ['EMAIL'] password = os.environ['PASSWORD'] print os.environ['SERVER'] conn = imaplib.IMAP4_SSL(os.environ['SERVER']) conn.login(user, password) conn.select() loop = True while loop: for uid, msg in conn.idle(): print uid, msg if msg == "EXISTS": conn.done() status, datas = conn.fetch(uid, '(RFC822)') m = MailRequest('localhost', None, None, datas[0][1]) print m.keys() print m.all_parts() print m.is_bounce()
def done(connection): connection.send("DONE\r\n".encode('utf8')) connection.loop = False imaplib.IMAP4.idle = idle imaplib.IMAP4.done = done if __name__ == '__main__': import os from lamson.mail import MailRequest user = os.environ['EMAIL'] password = os.environ['PASSWORD'] print(os.environ['SERVER']) conn = imaplib.IMAP4_SSL(os.environ['SERVER']) conn.login(user, password) conn.select() loop = True while loop: for uid, msg in conn.idle(): print(uid, msg) if msg == "EXISTS": conn.done() status, datas = conn.fetch(uid, '(RFC822)') m = MailRequest('localhost', None, None, datas[0][1]) print(m.keys()) print(m.all_parts()) print(m.is_bounce())
def done(connection): connection.send("DONE\r\n") connection.loop = False imaplib.IMAP4.idle = idle imaplib.IMAP4.done = done if __name__ == '__main__': import os from lamson.mail import MailRequest user = os.environ['EMAIL'] password = os.environ['PASSWORD'] print os.environ['SERVER'] conn = imaplib.IMAP4_SSL(os.environ['SERVER']) conn.login(user, password) conn.select() loop = True while loop: for uid, msg in conn.idle(): print uid, msg if msg == "EXISTS": conn.done() status, datas = conn.fetch(uid, '(RFC822)') m = MailRequest('localhost', None, None, datas[0][1]) print m.keys() print m.all_parts() print m.is_bounce()