Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
db7ed13b by Mark Sapiro at 2022-08-02T20:51:09+00:00
Reverse flattening messages as bytes for sending.

This reverses !1026 and !1029. See !1031 for why?

Also this reopens #1022 which is no longer even partially fixed.

- - - - -
23a278ea by Mark Sapiro at 2022-08-02T20:51:10+00:00
Merge branch 'send' into 'master'

Reverse flattening messages as bytes for sending.

See merge request mailman/mailman!1032
- - - - -


2 changed files:

- src/mailman/mta/base.py
- src/mailman/mta/connection.py


Changes:

=====================================
src/mailman/mta/base.py
=====================================
@@ -71,7 +71,7 @@ class BaseDelivery:
         # email address for predictability and testability.
         try:
             refused = self._connection.sendmail(
-                sender, sorted(recipients), msg.as_bytes())
+                sender, sorted(recipients), msg.as_string())
         except smtplib.SMTPRecipientsRefused as error:
             log.error('%s recipients refused: %s', message_id, error)
             refused = error.recipients


=====================================
src/mailman/mta/connection.py
=====================================
@@ -130,16 +130,7 @@ class Connection:
         # 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 can be a string or bytes. Handle either, but the result
-        # should be a string because passing bytes to smtplib.SMTP.sendmail
-        # doesn't convert the line endings.
-        if isinstance(msgtext, str):
-            msgtext = msgtext.encode('ascii', 'replace').decode('ascii')
-        else:
-            # We have to do this extra dance because we have to replace when
-            # encoding as ascii to avoid getting unicode unknowns.
-            msgtext = (msgtext.decode('ascii', 'replace').
-                       encode('ascii', 'replace').decode('ascii'))
+        msgtext = msgtext.encode('ascii', 'replace').decode('ascii')
         try:
             log.debug('envsender: %s, recipients: %s, size(msgtext): %s',
                       envsender, recipients, len(msgtext))



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/83f651f1fe0b1dfca06b2759e848c987b645ca59...23a278eab22d3a84ab7408b8eb26cce721ae030c

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/83f651f1fe0b1dfca06b2759e848c987b645ca59...23a278eab22d3a84ab7408b8eb26cce721ae030c
You're receiving this email because of your account on gitlab.com.


_______________________________________________
Mailman-checkins mailing list -- mailman-checkins@python.org
To unsubscribe send an email to mailman-checkins-le...@python.org
https://mail.python.org/mailman3/lists/mailman-checkins.python.org/
Member address: arch...@jab.org

Reply via email to