diff --git a/python/mailserver3.py b/python/mailserver3.py index acddc29..e66b53f 100644 --- a/python/mailserver3.py +++ b/python/mailserver3.py @@ -54,6 +54,12 @@ async def handle_DATA(self, server, session, envelope): else: filename = part.get_filename() cid = part.get('Content-ID') + if cid is not None: + cid = cid[1:-1] + elif part.get('Content-ID') is not None: + cid = part.get('Content-ID') + else: + cid = str(uuid.uuid4()) logger.debug('Handling attachment: "%s" of type "%s" with CID "%s"',filename, part.get_content_type(), cid) if filename is None: filename = 'untitled' @@ -106,7 +112,7 @@ async def handle_DATA(self, server, session, envelope): edata["attachments"].append(filenamebase+"-"+attd[0]) edata["attachments_details"].append({ "filename":attd[0], - "cid":attd[2][1:-1], + "cid":attd[2], "id":filenamebase+"-"+attd[0], "download_url":URL+"/api/attachment/"+em+"/"+filenamebase+"-"+attd[0], "size":len(attd[1]) diff --git a/tools/testmail-quotedprintable.txt b/tools/testmail-quotedprintable.txt new file mode 100644 index 0000000..da435a6 --- /dev/null +++ b/tools/testmail-quotedprintable.txt @@ -0,0 +1,30 @@ +EHLO example.com +MAIL FROM: +RCPT TO: +DATA +From: me +To: you +Subject: MIME encapsulation demo +Mime-Version: 1.0 +Content-type: multipart/alternative; boundary="covfefe" + +--covfefe +Content-type: text/plain; charset="utf-8" +Content-transfer-encoding: quoted-printable + +You had me at "H= +ello." + +--covfefe +Content-type: text/html; charset="utf-8" +Content-transfer-encoding: base64 + +PGh0bWw+PGhlYWQ+PHRpdGxlPkhlbGxvLCBpcyBpdCBtZSB5b3UncmUgbG9va2luZyBmb3I/PC +90aXRsZT48L2hlYWQ+PGJvZHk+PHA+VGhlIGNvdiBpbiB0aGUgZmUgZmU8L3A+PC9ib2R5Pjwv +aHRtbD4K + +--covfefe-- + +. + +QUIT