Skip to content

Commit

Permalink
Decided that experiment was not going to work, so switching back to u…
Browse files Browse the repository at this point in the history
…sing a remote SMTP server
  • Loading branch information
Murray Christopherson committed Apr 14, 2018
1 parent 41f735c commit bd18fca
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 323 deletions.
4 changes: 2 additions & 2 deletions quick_email/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def send_msg(msg, host, port, username=None, password=None, require_starttls=Fal
if require_starttls:
smtp.starttls()

if username and password:
smtp.login(username, password)
if username and password:
smtp.login(username, password)

_all_recipients = all_recipients(msg)

Expand Down
4 changes: 4 additions & 0 deletions tests/smtp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SMTP_HOST = os.environ[u'SMTP_HOST']
SMTP_PORT = int(os.environ.get(u'SMTP_PORT', u'25'))
SMTP_USERNAME = os.environ[u'SMTP_USERNAME']
SMTP_PASSWORD = os.environ[u'SMTP_PASSWORD']
Empty file removed tests/smtp/__init__.py
Empty file.
258 changes: 0 additions & 258 deletions tests/smtp/smtpd.py

This file was deleted.

45 changes: 0 additions & 45 deletions tests/smtp/smtpd_fake.py

This file was deleted.

16 changes: 5 additions & 11 deletions tests/test_quick_email.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import unittest

from quick_email import send_email
import tests.smtp.smtpd_fake as smtp
import tests.smtp as smtp

class TestQuickEmail(unittest.TestCase):
@classmethod
def setUpClass(cls):
smtp.smtp_server_start()

def test_send_email(self):
send_email(u'localhost', smtp.SMTP_PORT, u'Example <example@example.com>', u'The Subject', send_to=u'Test <test@test.com>', plain_text=u'Some Text', html_text=u'<b>Some Bold Text</b>')

def test_send_email_starttls(self):
send_email(u'localhost', smtp.SMTP_PORT, u'Example <example@example.com>', u'The Subject', send_to=u'Test <test@test.com>', plain_text=u'Some Text', html_text=u'<b>Some Bold Text</b>', require_starttls=True)
class TestQuickEmail(unittest.TestCase):
def test_send_email_auth(self):
send_email(smtp.SMTP_HOST, smtp.SMTP_PORT, u'Example <example@example.com>', u'The Subject', send_to=u'Test <test@test.com>', plain_text=u'Some Text', html_text=u'<b>Some Bold Text</b>', username=smtp.SMTP_USERNAME, password=smtp.SMTP_PASSWORD)

def test_send_email_starttls_auth(self):
send_email(u'localhost', smtp.SMTP_PORT, u'Example <example@example.com>', u'The Subject', send_to=u'Test <test@test.com>', plain_text=u'Some Text', html_text=u'<b>Some Bold Text</b>', username=u'testuser', password=u'password', require_starttls=True)
send_email(smtp.SMTP_HOST, smtp.SMTP_PORT, u'Example <example@example.com>', u'The Subject', send_to=u'Test <test@test.com>', plain_text=u'Some Text', html_text=u'<b>Some Bold Text</b>', username=smtp.SMTP_USERNAME, password=smtp.SMTP_PASSWORD, require_starttls=True)

if __name__ == u'__main__':
unittest.main()
10 changes: 3 additions & 7 deletions tests/test_sender.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import unittest

from quick_email import builder, sender
import tests.smtp.smtpd_fake as smtp
import tests.smtp as smtp


class TestSender(unittest.TestCase):
@classmethod
def setUpClass(cls):
smtp.smtp_server_start()

def test_minimal(self):
msg = builder.build_msg(u'Example <example@example.com>', u'The Subject', send_to=u'Test <test@test.com>', plain_text=u'Some Text', html_text=u'<b>Some Bold Text</b>')
sender.send_msg(msg, u'localhost', smtp.SMTP_PORT)
sender.send_msg(msg, smtp.SMTP_HOST, smtp.SMTP_PORT, username=smtp.SMTP_USERNAME, password=smtp.SMTP_PASSWORD, require_starttls=True)

def test_multiple_recipients(self):
msg = builder.build_msg(u'Example <example@example.com>', u'The Subject', send_to=u'Test <test@test.com>', send_cc=[u'Example <example@example.com>', u'Example2 <example2@example.com>'], send_bcc=u'Example3 <example3@example.com>', plain_text=u'Some Text', html_text=u'<b>Some Bold Text</b>')
sender.send_msg(msg, u'localhost', smtp.SMTP_PORT)
sender.send_msg(msg, u'localhost', smtp.SMTP_PORT, username=smtp.SMTP_USERNAME, password=smtp.SMTP_PASSWORD, require_starttls=True)


if __name__ == u'__main__':
Expand Down

0 comments on commit bd18fca

Please sign in to comment.