示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
 def _create_standard_mailer(self, config):
     return Mailer.from_settings(config, prefix='mail.')
示例#6
0
 def _create_standard_mailer(self, config):
     return Mailer.from_settings(config, prefix='mail.')