Exemplo n.º 1
0
    def test_unicode_subject(self):
        msg = Message(subject=make_lazy_string(lambda a: a, u"sübject"),
                      sender='*****@*****.**',
                      recipients=["*****@*****.**"])
        self.assertIn(b'=?utf-8?q?s=C3=BCbject?=', msg.as_bytes())

        subject = u"[Foo Bar] Voici vos paramètres d'accès à"
        msg = Message(subject=make_lazy_string(lambda a: a, subject),
                      sender='*****@*****.**',
                      recipients=["*****@*****.**"])
        self.assertIn(b'=?utf-8?b?W0ZvbyBCYXJdIFZvaWNpIHZvcyBwYX'
                      b'JhbcOodHJlcyBkJ2FjY8OocyDDoA==?=', msg.as_bytes())
Exemplo n.º 2
0
    def test_unicode_subject(self):
        msg = Message(subject=make_lazy_string(lambda a: a, u"sübject"),
                      sender='*****@*****.**',
                      recipients=["*****@*****.**"])
        self.assertIn(b'=?utf-8?q?s=C3=BCbject?=', msg.as_bytes())

        msg = Message(subject=make_lazy_string(lambda a: a, u"[Foo Bar] Voici vos paramètres d'accès à"),
                      sender='*****@*****.**',
                      recipients=["*****@*****.**"])
        self.assertIn(b'=?utf-8?b?W0ZvbyBCYXJdIFZvaWNpIHZvcyBwYXJhbcOodHJlcyBkJ2FjY8OocyDDoA==?=', msg.as_bytes())
Exemplo n.º 3
0
    def test_sendmail_with_ascii_body(self):
        with self.mail.connect() as conn:
            with mock.patch.object(conn, 'host') as host:
                msg = Message(subject="testing",
                              sender="*****@*****.**",
                              recipients=["*****@*****.**"],
                              body="body")
                conn.send(msg)

                host.sendmail.assert_called_once_with(
                    "*****@*****.**", ["*****@*****.**"],
                    msg.as_bytes() if PY3 else msg.as_string(),
                    msg.mail_options, msg.rcpt_options)
Exemplo n.º 4
0
    def test_sendmail_with_non_ascii_recipient(self):
        with self.mail.connect() as conn:
            with mock.patch.object(conn, 'host') as host:
                msg = Message(subject="testing",
                              sender="*****@*****.**",
                              recipients=[u'ÄÜÖ → ✓ <*****@*****.**>'],
                              body="testing")
                conn.send(msg)

                host.sendmail.assert_called_once_with(
                    "*****@*****.**",
                    ["=?utf-8?b?w4TDnMOWIOKGkiDinJM=?= <*****@*****.**>"],
                    msg.as_bytes() if PY3 else msg.as_string(),
                    msg.mail_options, msg.rcpt_options)
Exemplo n.º 5
0
    def test_sendmail_with_ascii_body(self):
        with self.mail.connect('default') as conn:
            with mock.patch.object(conn, 'host') as host:
                msg = Message(subject="testing",
                              sender="*****@*****.**",
                              recipients=["*****@*****.**"],
                              body="body")
                conn.send(msg)

                host.sendmail.assert_called_once_with(
                    "*****@*****.**",
                    ["*****@*****.**"],
                    msg.as_bytes() if PY3 else msg.as_string(),
                    msg.mail_options,
                    msg.rcpt_options
                )
Exemplo n.º 6
0
    def test_sendmail_with_non_ascii_recipient(self):
        with self.mail.connect('default') as conn:
            with mock.patch.object(conn, 'host') as host:
                msg = Message(subject="testing",
                              sender="*****@*****.**",
                              recipients=[u'ÄÜÖ → ✓ <*****@*****.**>'],
                              body="testing")
                conn.send(msg)

                host.sendmail.assert_called_once_with(
                    "*****@*****.**",
                    ["=?utf-8?b?w4TDnMOWIOKGkiDinJM=?= <*****@*****.**>"],
                    msg.as_bytes() if PY3 else msg.as_string(),
                    msg.mail_options,
                    msg.rcpt_options
                )
Exemplo n.º 7
0
 def test_send_with_whitelist(self):
     with self.mail_config(domain_whitelist=["@whitelist.example.com"]):
         with self.mail.connect() as conn:
             with mock.patch.object(conn, "host") as host:
                 msg = Message(
                     subject="testing",
                     recipients=["*****@*****.**", "*****@*****.**"],
                     body="testing",
                 )
                 conn.send(msg)
                 host.sendmail.assert_called_once_with(
                     u"*****@*****.**",
                     ["*****@*****.**"],
                     msg.as_bytes() if PY3 else msg.as_string(),
                     msg.mail_options,
                     msg.rcpt_options
                 )