Beispiel #1
0
def test_connection_send_ascii_recipient_single():
    mail = Mail(**test_mail_options)
    msg = Message(sender="*****@*****.**",
                  recipients=["*****@*****.**"],
                  body="normal ascii text")
    with mail.connect() as conn:
        with patch.object(conn, 'host') as host:
            conn.send(msg)
            host.sendmail.assert_called_once_with(msg.sender, msg.recipients,
                                                  msg.as_bytes(),
                                                  msg.mail_options,
                                                  msg.rcpt_options)
Beispiel #2
0
def test_connection_send_single(mock_smtp):
    mail = Mail(**test_mail_options)
    mail.mail_suppress_send = False
    msg = Message(sender="*****@*****.**",
                  recipients=["*****@*****.**"],
                  body="normal ascii text")
    mock_smtp.return_value = MagicMock(spec=SMTP)
    with mail.connect() as conn:
        conn.send(msg)
        host = conn.host
        host.sendmail.assert_called_with(msg.sender, msg.recipients,
                                         msg.as_bytes(), msg.mail_options,
                                         msg.rcpt_options)
Beispiel #3
0
def test_connection_send_non_ascii_recipient_single():
    mail = Mail(**test_mail_options)
    with mail.connect() as conn:
        with 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(), msg.mail_options, msg.rcpt_options)
Beispiel #4
0
def test_message_as_bytes():
    msg = Message(sender="*****@*****.**", recipients=["*****@*****.**"])
    msg.body = "normal ascii text"
    assert bytes(msg) == msg.as_bytes()