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)
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")
def test_email_address(self): an_email = Email() an_email.set_address('*****@*****.**') self.assertEqual(an_email.address, '*****@*****.**')
def test_smtp(self): an_email = Email() an_email.set_smtp_server('smtp.gmail.com') self.assertEqual(an_email.smtp, 'smtp.gmail.com')
def test_port(self): an_email = Email() an_email.set_port(444) self.assertEqual(an_email.port, 444)
def test_password(self): an_email = Email() an_email.set_password('mypass') self.assertEqual(an_email.password, 'mypass')