Esempio n. 1
0
    def test_multi_recip(self):
        email = EmailMessage('Subject', 'Content', '*****@*****.**',
                             ['*****@*****.**', '*****@*****.**'])
        message = email.message()

        assert message['Subject'].encode() == 'Subject'
        assert message.get_payload() == 'Content'
        assert message['From'] == '*****@*****.**'
        assert message['To'] == '[email protected], [email protected]'
        assert email.recipients() == ['*****@*****.**', '*****@*****.**']
Esempio n. 2
0
    def test_normal_ascii(self):
        """Test normal ascii character case"""
        email = EmailMessage('Subject', 'Content', '*****@*****.**', ['*****@*****.**'])
        message = email.message()

        assert message['Subject'].encode() == 'Subject'
        assert message.get_payload() == 'Content'
        assert message['From'] == '*****@*****.**'
        assert message['To'] == '*****@*****.**'
        assert email.recipients() == ['*****@*****.**']
Esempio n. 3
0
    def test_bcc_defaults(self):
        settings.emails.bcc_defaults = ['*****@*****.**', '*****@*****.**']
        email = EmailMessage('Subject', 'Content', to=['*****@*****.**'])
        message = email.message()

        assert message['Subject'].encode() == 'Subject'
        assert message.get_payload() == 'Content'
        assert message['From'] == 'root@localhost'
        assert message['To'] == '*****@*****.**'
        assert email.recipients() == ['*****@*****.**', '*****@*****.**', '*****@*****.**']

        email = EmailMessage('Subject', 'Content', to=['*****@*****.**'], bcc=['*****@*****.**'])
        message = email.message()

        assert message['Subject'].encode() == 'Subject'
        assert message.get_payload() == 'Content'
        assert message['From'] == 'root@localhost'
        assert message['To'] == '*****@*****.**'
        assert email.recipients() == ['*****@*****.**', '*****@*****.**']
Esempio n. 4
0
    def test_cc(self):
        email = EmailMessage('Subject', 'Content', to=['*****@*****.**'],
                             cc=['*****@*****.**', '*****@*****.**'])
        message = email.message()

        assert message['Subject'].encode() == 'Subject'
        assert message.get_payload() == 'Content'
        assert message['From'] == 'root@localhost'
        assert message['To'] == '*****@*****.**'
        assert message['Cc'] == '[email protected], [email protected]'
        assert email.recipients() == ['*****@*****.**', '*****@*****.**', '*****@*****.**']
Esempio n. 5
0
    def test_overrides(self, mm_tracker=None):
        """Test overrides"""

        settings.emails.override = '*****@*****.**'
        email = EmailMessage('Subject', 'Content', '*****@*****.**', ['*****@*****.**'],
                             cc=['*****@*****.**'], bcc=['*****@*****.**'])
        message = email.message()

        assert message['Subject'].encode() == 'Subject'
        assert message['From'] == '*****@*****.**'
        assert message['To'] == '*****@*****.**'
        assert message['Cc'] is None
        assert email.recipients() == ['*****@*****.**']

        msg_string = message.as_string()
        assert '-' * 70 in msg_string
        assert '\n\nTo: [email protected]' in msg_string
        assert '\nCc: [email protected]' in msg_string
        assert '\nBcc: [email protected]' in msg_string
        assert '\nContent' in msg_string
Esempio n. 6
0
    def test_overrides_recipients_first(self):
        """
            Test overrides, but call recipients first just like the code does
            when sending an email
        """

        settings.emails.override = '*****@*****.**'
        email = EmailMessage('Subject', 'Content', '*****@*****.**', ['*****@*****.**'],
                             cc=['*****@*****.**'], bcc=['*****@*****.**'])
        assert email.recipients() == ['*****@*****.**']

        message = email.message()
        assert message['Subject'].encode() == 'Subject'
        assert message['From'] == '*****@*****.**'
        assert message['To'] == '*****@*****.**'
        assert message['Cc'] is None

        msg_string = message.as_string()
        assert '-' * 70 in msg_string
        assert '\n\nTo: [email protected]' in msg_string
        assert '\nCc: [email protected]' in msg_string
        assert '\nBcc: [email protected]' in msg_string
        assert '\nContent' in msg_string