about summary refs log tree commit diff
path: root/overlays/patches/mailman/no-base64.diff
blob: 2deef3ec3cf075844204a863f8fd1f7d1d1c512c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff --git i/src/mailman/email/message.py w/src/mailman/email/message.py
index fd6a28144..693f8d2b7 100644
--- i/src/mailman/email/message.py
+++ w/src/mailman/email/message.py
@@ -49,6 +49,11 @@ class Message(email.message.Message):
         self.__dict__ = values
 
     def as_string(self):
+        try:
+            return email.message.Message.as_bytes(self).decode('utf-8')
+        except UnicodeEncodeError:
+            pass
+
         # Work around for https://bugs.python.org/issue27321 and
         # https://bugs.python.org/issue32330.
         try:
diff --git i/src/mailman/mta/connection.py w/src/mailman/mta/connection.py
index ebcc19eb4..e69fe4c6a 100644
--- i/src/mailman/mta/connection.py
+++ w/src/mailman/mta/connection.py
@@ -127,10 +127,9 @@ class Connection:
         if self._connection is None:
             self._connect()
             self._login()
-        # smtplib.SMTP.sendmail requires the message string to be pure ascii.
-        # We have seen malformed messages with non-ascii unicodes, so ensure
-        # we have pure ascii.
-        msgtext = msgtext.encode('ascii', 'replace').decode('ascii')
+        # smtplib.SMTP.sendmail requires the message string to be
+        # bytes or an ASCII string.
+        msgtext = msgtext.encode('utf-8')
         try:
             log.debug('envsender: %s, recipients: %s, size(msgtext): %s',
                       envsender, recipients, len(msgtext))