summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/model/mail.py
diff options
context:
space:
mode:
authorDuda Dornelles <dudassdornelles@gmail.com>2015-01-09 13:11:33 -0200
committerPixpoa pairing <pixpoapairing@pixelated-project.org>2015-01-09 13:18:34 -0200
commit68a893237c9cdf67f91909981e024d7bf306b73c (patch)
tree1ee43c3204e07cf05a5222c3de4680e0068c8ba5 /service/pixelated/adapter/model/mail.py
parent69a0650615935e7fd6a20656c4248b95cbe10317 (diff)
#164 sometimes a mail with more than one alternative will not have an html part
Diffstat (limited to 'service/pixelated/adapter/model/mail.py')
-rw-r--r--service/pixelated/adapter/model/mail.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/service/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py
index 98533a74..7984cb05 100644
--- a/service/pixelated/adapter/model/mail.py
+++ b/service/pixelated/adapter/model/mail.py
@@ -236,8 +236,9 @@ class PixelatedMail(Mail):
@property
def html_body(self):
if self.parts and len(self.alternatives) > 1:
- html_part = [e for e in self.alternatives if re.match('text/html', e['headers']['Content-Type'])][0]
- return self._decode_part(html_part)
+ html_parts = [e for e in self.alternatives if re.match('text/html', e['headers'].get('Content-Type', ''))]
+ if len(html_parts):
+ return self._decode_part(html_parts[0])
@property
def headers(self):