diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-06-07 06:22:16 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-06-07 06:22:16 -0300 |
commit | b0305a6645138e12307c0cfb86461c6705b31664 (patch) | |
tree | c7b40e0ba7098466282a341e506dbeb5ffc6e4cd /service/pixelated/adapter/services | |
parent | ba6068175133eb08dd15877315d4d3361d35bdbc (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.py | 9 |
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()) |