summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-02-05 11:21:48 +0100
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-02-05 15:26:58 +0100
commit9893a5409560e1cc7123ec42d12b49e6edd6283c (patch)
tree3933147ea994a4ea71536d0c6be084827418f56d /service/pixelated/adapter
parenta471b8e494b46fd85022b2105eee50fec4f84996 (diff)
(Re-)added error handling for twisted smtp sender.
- Issue #249 - Fixed all tests with that rely on sendmail deferred.
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r--service/pixelated/adapter/services/mail_sender.py6
-rw-r--r--service/pixelated/adapter/services/mail_service.py8
2 files changed, 8 insertions, 6 deletions
diff --git a/service/pixelated/adapter/services/mail_sender.py b/service/pixelated/adapter/services/mail_sender.py
index d29b7d49..24ae839d 100644
--- a/service/pixelated/adapter/services/mail_sender.py
+++ b/service/pixelated/adapter/services/mail_sender.py
@@ -22,7 +22,7 @@ from twisted.internet import reactor
from pixelated.support.functional import flatten
-class MailSender():
+class MailSender(object):
def __init__(self, account_email_address, smtp_client=None):
self.account_email_address = account_email_address
@@ -41,11 +41,11 @@ class MailSender():
def sendmail(self, mail):
recipients = flatten([mail.to, mail.cc, mail.bcc])
- normalized_recepients = self.get_email_addresses(recipients)
+ normalized_recipients = self.get_email_addresses(recipients)
resultDeferred = Deferred()
senderFactory = SMTPSenderFactory(
fromEmail=self.account_email_address,
- toEmail=normalized_recepients,
+ toEmail=normalized_recipients,
file=StringIO(mail.to_smtp_format()),
deferred=resultDeferred)
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py
index 6e309ee0..1e0a0414 100644
--- a/service/pixelated/adapter/services/mail_service.py
+++ b/service/pixelated/adapter/services/mail_service.py
@@ -55,10 +55,12 @@ class MailService:
mail = InputMail.from_dict(content_dict)
draft_id = content_dict.get('ident')
- self.mail_sender.sendmail(mail)
- sent_mail = self.move_to_sent(draft_id, mail)
+ def move_to_sent(_):
+ return self.move_to_sent(draft_id, mail)
- return sent_mail
+ deferred = self.mail_sender.sendmail(mail)
+ deferred.addCallback(move_to_sent)
+ return deferred
def move_to_sent(self, last_draft_ident, mail):
if last_draft_ident: