diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-09-19 11:19:45 -0300 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-09-19 11:19:45 -0300 |
commit | 610d356c0ad2e9ea47946f0212a945ed663d0106 (patch) | |
tree | 936d0826481e376037067d95f03f5faddf925f28 /service/pixelated | |
parent | 90aff82d713e4c288612ad8c339e7613be706781 (diff) |
PixelatedMail#to_smtp_format shouldnt add empty fields
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/adapter/pixelated_mail.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py index 5c3025b6..6d5a9335 100644 --- a/service/pixelated/adapter/pixelated_mail.py +++ b/service/pixelated/adapter/pixelated_mail.py @@ -138,10 +138,14 @@ class PixelatedMail: def to_mime_multipart(self): mime_multipart = MIMEMultipart() - mime_multipart['To'] = ", ".join(self.headers['to']) - mime_multipart['Cc'] = ", ".join(self.headers['cc']) - mime_multipart['Bcc'] = ", ".join(self.headers['bcc']) - mime_multipart['Subject'] = self.headers['subject'] + + for header in ['To', 'Cc', 'Bcc']: + if self.headers[header.lower()]: + mime_multipart[header] = ", ".join(self.headers[header.lower()]) + + if self.headers['subject']: + mime_multipart['Subject'] = self.headers['subject'] + mime_multipart['Date'] = self.headers['date'] mime_multipart.attach(MIMEText(self.body, 'plain')) return mime_multipart |