def test_cc_without_recipients(self): from tgext.mailer.message import Message from tgext.mailer.mailer import Mailer msg = Message( subject="testing", sender="*****@*****.**", body="testing", cc=["*****@*****.**"] ) mailer = Mailer() msgid = mailer.send(msg) response = msg.to_message() self.assertTrue("Cc: [email protected]" in text_type(response)) self.assertTrue(msgid)
def test_send_without_body(self): from tgext.mailer.message import Message from tgext.mailer.mailer import Mailer from tgext.mailer.exceptions import InvalidMessage msg = Message( subject="testing", sender="*****@*****.**", recipients=["*****@*****.**"] ) mailer = Mailer() self.assertRaises(InvalidMessage, mailer.send, msg) msg.html = "<b>test</b>" mailer.send(msg)
def test_send_without_recipients(self): from tgext.mailer.message import Message from tgext.mailer.mailer import Mailer from tgext.mailer.exceptions import InvalidMessage mailer = Mailer() msg = Message( subject="testing", recipients=[], body="testing" ) self.assertRaises(InvalidMessage, mailer.send, msg)
def test_bad_header_sender(self): from tgext.mailer.message import Message from tgext.mailer.mailer import Mailer from tgext.mailer.exceptions import BadHeaders mailer = Mailer() msg = Message( subject="testing", sender="[email protected]\n\r", recipients=["*****@*****.**"], body="testing" ) self.assertRaises(BadHeaders, mailer.send, msg)
def _create_standard_mailer(self, config): return Mailer.from_settings(config, prefix='mail.')