Open thestick613 opened 7 years ago
Try something like this. It fixed my issues with odd utf-8 in the Subject header.
diff --git a/slimta/util/pycompat.py b/slimta/util/pycompat.py
index f81edad..eea5dac 100644
--- a/slimta/util/pycompat.py
+++ b/slimta/util/pycompat.py
@@ -47,9 +47,14 @@ if PY3:
from email.generator import BytesGenerator
from email.parser import BytesParser
- from email.policy import SMTP
- parser = partial(BytesParser, policy=SMTP)
- generator = partial(BytesGenerator, policy=SMTP)
+ from email.policy import compat32
+
+ # compat32 doesn't decode headers and leaves
+ # them as-is 7-bit - so less Unicode errors
+
+ custom = compat32.clone(linesep='\r\n')
+ parser = partial(BytesParser, policy=custom)
+ generator = partial(BytesGenerator, policy=custom)
else:
from itertools import imap
map_func = imap