Esempio n. 1
0
def test_fail_silently():
    mailer = SMTPMailer(host='127.0.0.1', port=8000, use_tls=True,
        fail_silently=True)
    mailer.open()
    
    mailer = SMTPMailer(host='123', port=8000, use_tls=False,
        fail_silently=True)
    mailer.open()

    mailer = SMTPMailer(host='127.0.0.1', port=3000, use_tls=False,
        fail_silently=True)
    mailer.open()
Esempio n. 2
0
def test_sending():
    global server
    server.flush_sink()
    
    mailer = SMTPMailer(host='127.0.0.1', port=8000, use_tls=False)
    email1, email2, email3, email4 = make_emails()

    assert mailer.send(email1) == 1
    assert mailer.send(email2, email3) == 2
    assert mailer.send(email4) == 1

    sink = server.get_sink()
    assert len(sink) == 4

    message = sink[0]
    print message
    assert message.get_content_type() == 'text/plain'
    assert message.get('subject') == 'Subject-1'
    assert message.get('from') == '*****@*****.**'
    assert message.get('to') == '*****@*****.**'
Esempio n. 3
0
def test_wrong_port():
    with pytest.raises(Exception):
        mailer = SMTPMailer(host='127.0.0.1', port=3000, use_tls=False)
        mailer.open()
Esempio n. 4
0
def test_notls():
    with pytest.raises(SMTPException):
        mailer = SMTPMailer(host='127.0.0.1', port=8000, use_tls=True)
        mailer.open()