Пример #1
0
from app_email import Email, Message

em = Email()
msg = Message()

msg.set_receiver("*****@*****.**")
em.set_address("*****@*****.**")
em.set_smtp_server("smtp.mailtrap.io")
em.set_port(2525)
em.set_username("c123d2a294f857")
em.set_password("07dc82c500f623")
em.set_email_name('Rey')

message = f"""\
Subject: Hi Mailtrap - SSL
To: {msg.receiver}
From: {em.email_name} <{em.address}>

This is a test e-mail message from SSL."""

message_open = f"""\
Subject: Hi Mailtrap - Open
To: {msg.receiver}
From: {em.email_name} <{em.address}>

This is a test e-mail message from Open."""

msg.send_text_email(em, message_open)

msg.send_ssl_text_email(em, message)
Пример #2
0
    def test_send_ssl_text_email(self):
        em = Email()
        msg = Message()

        msg.set_receiver("*****@*****.**")
        em.set_address("*****@*****.**")
        em.set_smtp_server("smtp.mailtrap.io")
        em.set_port(2525)
        em.set_username("c123d2a294f857")
        em.set_password("07dc82c500f623")
        em.set_email_name('A user')

        message = f"""\
        Subject: Hi Mailtrap - SSL email
        To: {msg.receiver}
        From: {em.email_name} <{em.address}>
            
        This is a test e-mail message with SSL."""

        self.assertEqual(msg.send_ssl_text_email(em, message), "Message Sent")
Пример #3
0
 def test_email_address(self):
     an_email = Email()
     an_email.set_address('*****@*****.**')
     self.assertEqual(an_email.address, '*****@*****.**')
Пример #4
0
 def test_smtp(self):
     an_email = Email()
     an_email.set_smtp_server('smtp.gmail.com')
     self.assertEqual(an_email.smtp, 'smtp.gmail.com')
Пример #5
0
 def test_port(self):
     an_email = Email()
     an_email.set_port(444)
     self.assertEqual(an_email.port, 444)
Пример #6
0
 def test_password(self):
     an_email = Email()
     an_email.set_password('mypass')
     self.assertEqual(an_email.password, 'mypass')