summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter
diff options
context:
space:
mode:
authorJefferson Stachelski <jstachel@thoughtworks.com>2015-01-30 14:04:16 -0200
committerPixpoa pairing <pixpoapairing@pixelated-project.org>2015-01-30 14:08:35 -0200
commitcad4bbf073663db828fa7ac43b27ae00556e2797 (patch)
tree9ddc691b5b687726e665ee8422afe7751e83493a /service/pixelated/adapter
parenta484020944f7e89200f6b0d86e72084f0dec5491 (diff)
249 Implemented a feature that send an email when something was wrong to send email
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r--service/pixelated/adapter/model/mail.py11
-rw-r--r--service/pixelated/adapter/services/mail_service.py16
2 files changed, 17 insertions, 10 deletions
diff --git a/service/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py
index 42953064..dfc0ea1c 100644
--- a/service/pixelated/adapter/model/mail.py
+++ b/service/pixelated/adapter/model/mail.py
@@ -186,6 +186,17 @@ class InputMail(Mail):
return mime_multipart.as_string()
@staticmethod
+ def delivery_error_template(delivery_address):
+ return InputMail.from_dict({
+ 'body': "Mail undelivered for %s" % delivery_address,
+ 'header': {
+ 'bcc': [],
+ 'cc': [],
+ 'subject': "Mail undelivered for %s" % delivery_address
+ }
+ })
+
+ @staticmethod
def from_dict(mail_dict):
input_mail = InputMail()
input_mail.headers = {key.capitalize(): value for key, value in mail_dict.get('header', {}).items()}
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py
index 26b4e162..7bf76676 100644
--- a/service/pixelated/adapter/services/mail_service.py
+++ b/service/pixelated/adapter/services/mail_service.py
@@ -13,8 +13,6 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
-
-
class MailService:
__slots__ = ['leap_session', 'account', 'mailbox_name']
@@ -44,15 +42,13 @@ class MailService:
def mail_exists(self, mail_id):
return not(not(self.querier.get_header_by_chash(mail_id)))
- def send(self, last_draft_ident, mail):
- result = self.mail_sender.sendmail(mail)
+ def send(self, mail):
+ self.mail_sender.sendmail(mail)
- def success(_):
- if last_draft_ident:
- self.mailboxes.drafts().remove(last_draft_ident)
- return self.mailboxes.sent().add(mail)
- result.addCallback(success)
- return result
+ def move_to_send(self, last_draft_ident, mail):
+ if last_draft_ident:
+ self.mailboxes.drafts().remove(last_draft_ident)
+ return self.mailboxes.sent().add(mail)
def mark_as_read(self, mail_id):
return self.mail(mail_id).mark_as_read()