summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/services
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2015-06-07 06:22:16 -0300
committerVictor Shyba <victor.shyba@gmail.com>2015-06-07 06:22:16 -0300
commitb0305a6645138e12307c0cfb86461c6705b31664 (patch)
treec7b40e0ba7098466282a341e506dbeb5ffc6e4cd /service/pixelated/adapter/services
parentba6068175133eb08dd15877315d4d3361d35bdbc (diff)
smtp with better variable naming and random port
Diffstat (limited to 'service/pixelated/adapter/services')
-rw-r--r--service/pixelated/adapter/services/mail_sender.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/service/pixelated/adapter/services/mail_sender.py b/service/pixelated/adapter/services/mail_sender.py
index bbcc1721..262a6e18 100644
--- a/service/pixelated/adapter/services/mail_sender.py
+++ b/service/pixelated/adapter/services/mail_sender.py
@@ -29,12 +29,12 @@ class SMTPDownException(Exception):
class MailSender(object):
- def __init__(self, account_email_address, ensure_smtp_is_running_cb):
- self.ensure_smtp_is_running_cb = ensure_smtp_is_running_cb
+ def __init__(self, account_email_address, smtp):
+ self.smtp = smtp
self.account_email_address = account_email_address
def sendmail(self, mail):
- if self.ensure_smtp_is_running_cb():
+ if self.smtp.ensure_running():
recipients = flatten([mail.to, mail.cc, mail.bcc])
result_deferred = Deferred()
sender_factory = SMTPSenderFactory(
@@ -43,7 +43,8 @@ class MailSender(object):
file=StringIO(mail.to_smtp_format()),
deferred=result_deferred)
- reactor.connectTCP('localhost', 4650, sender_factory)
+ reactor.connectTCP('localhost', self.smtp.local_smtp_port_number,
+ sender_factory)
return result_deferred
return fail(SMTPDownException())