def test_cc_without_recipients_2(self): from pyramid_mailer.message import Message msg = Message(subject="testing", sender="*****@*****.**", body="testing", cc=["*****@*****.**"]) response = msg.to_message() self.assertTrue("Cc: [email protected]" in text_type(response))
def test_message_is_quoted_printable_with_text_body(self): from pyramid_mailer.message import Message msg = Message( recipients=['*****@*****.**'], subject="testing", sender="*****@*****.**", body="THISSHOULDBEINMESSAGEBODY", ) response = msg.to_message() self.assertTrue("THISSHOULDBEINMESSAGEBODY" in text_type(response))
def test_to_message_multiple_to_recipients(self): from pyramid_mailer.message import Message response = Message( subject="Subject", sender="From", recipients=["*****@*****.**", "*****@*****.**"], body="Body", html="Html", ) message = response.to_message() self.assertEqual(text_type(message['To']), '[email protected], [email protected]')
def test_extra_headers(self): from pyramid_mailer.message import Message msg = Message(subject="testing", sender="*****@*****.**", recipients=["*****@*****.**"], body="testing", extra_headers=[('X-Foo', 'Joe')]) response = msg.to_message() self.assertTrue("X-Foo: Joe" in text_type(response))
def test_bcc_without_recipients(self): from pyramid_mailer.message import Message from pyramid_mailer.mailer import Mailer msg = Message(subject="testing", sender="*****@*****.**", body="testing", bcc=["*****@*****.**"]) mailer = Mailer() msgid = mailer.send(msg) response = msg.to_message() self.assertFalse("Bcc: [email protected]" in text_type(response)) self.assertTrue(msgid)
def test_extra_headers(self): from pyramid_mailer.message import Message msg = Message( subject="testing", sender="*****@*****.**", recipients=["*****@*****.**"], body="testing", extra_headers=[('X-Foo', 'Joe')] ) response = msg.to_message() self.assertTrue("X-Foo: Joe" in text_type(response))
def test_bcc_without_recipients(self): from pyramid_mailer.message import Message from pyramid_mailer.mailer import Mailer msg = Message(subject="testing", sender="*****@*****.**", body="testing", bcc=["*****@*****.**"]) mailer = Mailer() msgid = mailer.send(msg) response = msg.to_message() self.assertFalse( "Bcc: [email protected]" in text_type(response)) self.assertTrue(msgid)
def test_data_from_file_obj(self): a = self._makeOne(data=StringIO(text_type("foo"))) self.assertEqual(a.data, "foo")