Skip to content

Commit

Permalink
added decoding of subjects. should fix #73
Browse files Browse the repository at this point in the history
  • Loading branch information
geek-at committed Jan 23, 2024
1 parent b4c31de commit e5dadc5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/mailserver3.py
Expand Up @@ -3,6 +3,7 @@
import ssl
from aiosmtpd.controller import Controller
from email.parser import BytesParser
from email.header import decode_header, make_header
from email import policy
import os
import re
Expand Down Expand Up @@ -52,6 +53,8 @@ async def handle_DATA(self, server, session, envelope):

# Parse the email
message = BytesParser(policy=policy.default).parsebytes(envelope.content)
subject = str(make_header(decode_header(message['subject'])))


# Separate HTML and plaintext parts
plaintext = ''
Expand Down Expand Up @@ -99,7 +102,7 @@ async def handle_DATA(self, server, session, envelope):


edata = {
'subject': message['subject'],
'subject': subject,
'body': plaintext,
'htmlbody': self.replace_cid_with_attachment_id(html, attachments,filenamebase,em),
'from': message['from'],
Expand Down

0 comments on commit e5dadc5

Please sign in to comment.