From b0305a6645138e12307c0cfb86461c6705b31664 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Sun, 7 Jun 2015 06:22:16 -0300 Subject: smtp with better variable naming and random port --- service/pixelated/adapter/services/mail_sender.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'service/pixelated/adapter/services') 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()) -- cgit v1.2.3