diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2011-10-29 18:49:28 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2011-10-29 18:49:28 +0100 |
commit | 939f30e90dc9617966356b333bff92d95ae19221 (patch) | |
tree | 7fc3a0a991d28efd4c6200958c73a653ae8ce25d /alot/helper.py | |
parent | b66ccfd799f60c14d94eba8a1b9ca4c20e52674a (diff) |
correctly attach to non-multipart msgs
Diffstat (limited to 'alot/helper.py')
-rw-r--r-- | alot/helper.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/alot/helper.py b/alot/helper.py index e9661642..bb450352 100644 --- a/alot/helper.py +++ b/alot/helper.py @@ -29,12 +29,13 @@ from email.mime.audio import MIMEAudio from email.mime.base import MIMEBase from email.mime.image import MIMEImage from email.mime.text import MIMEText +from email.mime.multipart import MIMEMultipart import urwid from settings import config -def string_sanitize(string, tab_width = None): +def string_sanitize(string, tab_width=None): r""" strips, and replaces non-printable characters @@ -254,7 +255,16 @@ def attach(path, mail, filename=None): filename = os.path.basename(path) part.add_header('Content-Disposition', 'attachment', filename=filename) + #wrap in multipart if not already + if not mail.is_multipart(): + newmail = MIMEMultipart() + #move headers to new outer mail + for k in mail.keys(): + newmail[k] = mail[k] + del(mail[k]) + mail = newmail mail.attach(part) + return mail def shell_quote(text): |