Handle plaintext and gzipped attachments

This commit is contained in:
Peter J. Holzer 2019-03-04 21:49:46 +01:00
parent 48fcf768ae
commit d32c60a318
1 changed files with 7 additions and 2 deletions

View File

@ -54,8 +54,10 @@ def save_part(msg):
content_type = msg.get_content_type()
extension = {
"application/octet-stream": ".bin",
"text/html": ".html",
"text/x-vcard": ".vcf",
"text/html": ".html",
"text/x-vcard": ".vcf",
"text/plain": ".txt",
"application/x-gzip": ".gz", # more likely tar.gz, but we can't know without looking into it which we ain't
}[content_type]
name = msg.get_param("name") or "(data)"
@ -238,6 +240,9 @@ def render_body(msg):
}
bodyhtml = bodytmpl.render(context)
elif content_type == "application/x-gzip":
bodyhtml = save_part(msg)
else:
raise RuntimeError("Content-type " + content_type + " not implemented yet")