summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2016-08-09 20:08:32 (GMT)
committerSerghei Mihai <smihai@entrouvert.com>2016-09-01 09:37:52 (GMT)
commite61e5a5381511b621826e42608a4d9de3ff57fdc (patch)
tree84b83fca783eedbec504685ab143e5c68cf65d61
parent834bb8ebcf8b0b909cdec4164a9b670e456c24fc (diff)
downloadmail2redmine-e61e5a5381511b621826e42608a4d9de3ff57fdc.zip
mail2redmine-e61e5a5381511b621826e42608a4d9de3ff57fdc.tar.gz
mail2redmine-e61e5a5381511b621826e42608a4d9de3ff57fdc.tar.bz2
keep all attachments (fixes #12849)
-rw-r--r--mail2redmine.py24
1 files changed, 10 insertions, 14 deletions
diff --git a/mail2redmine.py b/mail2redmine.py
index 89ac06b..d469354 100644
--- a/mail2redmine.py
+++ b/mail2redmine.py
@@ -36,21 +36,17 @@ def parse_header(header_text):
headers[i] = unicode(text, charset or default_charset, errors='replace')
return u' '.join(headers)
+
def parse_attachment(data):
- disposition = data.get('Content-Disposition')
- if disposition:
- dispositions = disposition.strip().split(";")
- if dispositions[0] == "attachment":
- file_data = data.get_payload(decode=True)
- with tempfile.NamedTemporaryFile(delete=False) as attachment:
- attachment.write(file_data)
- attachment.flush()
- temp = tempfile.NamedTemporaryFile(delete=False)
- attachment = {'path': attachment.name,
- 'content_type': data.get_content_type(),
- 'filename': parse_header(data.get_filename())}
- return attachment
- return None
+ file_data = data.get_payload(decode=True)
+ with tempfile.NamedTemporaryFile(delete=False) as attachment:
+ attachment.write(file_data)
+ attachment.flush()
+ attachment = {'path': attachment.name,
+ 'content_type': data.get_content_type(),
+ 'filename': parse_header(data.get_filename())}
+ return attachment
+
def send_mail(to, subject, message):
s = smtplib.SMTP('localhost')