def test_reply_to(self): msg = Message(subject="testing", recipients=["*****@*****.**"], sender="spammer <*****@*****.**>", reply_to="somebody <*****@*****.**>", body="testing") response = msg.as_string() h = Header("Reply-To: %s" % sanitize_address('somebody <*****@*****.**>')) self.assertIn(h.encode(), str(response))
def test_unicode_headers(self): msg = Message(subject="subject", sender=u'ÄÜÖ → ✓ <*****@*****.**>', recipients=[u"Ä <*****@*****.**>", u"Ü <*****@*****.**>"], cc=[u"Ö <*****@*****.**>"]) response = msg.as_string() a1 = sanitize_address(u"Ä <*****@*****.**>") a2 = sanitize_address(u"Ü <*****@*****.**>") h1_a = Header("To: %s, %s" % (a1, a2)) h1_b = Header("To: %s, %s" % (a2, a1)) h2 = Header("From: %s" % sanitize_address(u"ÄÜÖ → ✓ <*****@*****.**>")) h3 = Header("Cc: %s" % sanitize_address(u"Ö <*****@*****.**>")) # Ugly, but there's no guaranteed order of the recipieints in the header try: self.assertIn(h1_a.encode(), response) except AssertionError: self.assertIn(h1_b.encode(), response) self.assertIn(h2.encode(), response) self.assertIn(h3.encode(), response)