You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary: after upgrading from Python 3.12.0 to 3.12.1, the to_addrs argument of smtplib.SMTP.send_message() is no longer automatically inferred from the email contents, as they were before and as they should according to the documentation. This seems to occur only if Cc and Bcc are both set and empty.
Reproduction:
Install Python 3.12.1.
Run a TCP server on localhost:1025 that simulates a SMTP server, e.g. with netcat: nc -v -l 1025.
Use Python smtplib.SMTP.send_message() to send an email:
Optionally print(msg) to see the exact bytes being sent:
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: Me <me@me.me>
To: You <you@you.you>
Cc:
Bcc:
Email body.
Receive the email and see the bug. For instance with netcat, simulate the SMTP protocol by typing 220 HELO then 220 HELO then 250 OK:
Ncat: Version 7.93 ( https://nmap.org/ncat )
Ncat: Listening on :::1025
Ncat: Listening on 0.0.0.0:1025
Ncat: Connection from ::1.
Ncat: Connection from ::1:42194.
220 HELO
ehlo localhost.localdomain
220 HELO
mail FROM:<me@me.me>
250 OK
rcpt TO:<>
In the data received, rcpt TO:<> should be rcpt TO:<you@you.you>.
Possibles fixes to avoid this bug:
Downgrade to Python 3.12.0.
Remove either of Cc or Bcc from the message.
Explicitely set to_addrs=... in SMTP.send_message().
Bug report
Bug description:
Summary: after upgrading from Python 3.12.0 to 3.12.1, the
to_addrsargument ofsmtplib.SMTP.send_message()is no longer automatically inferred from the email contents, as they were before and as they should according to the documentation. This seems to occur only ifCcandBccare both set and empty.Reproduction:
Install Python 3.12.1.
Run a TCP server on
localhost:1025that simulates a SMTP server, e.g. with netcat:nc -v -l 1025.Use Python
smtplib.SMTP.send_message()to send an email:Optionally
print(msg)to see the exact bytes being sent:Receive the email and see the bug. For instance with netcat, simulate the SMTP protocol by typing
220 HELOthen220 HELOthen250 OK:In the data received,
rcpt TO:<>should bercpt TO:<you@you.you>.Possibles fixes to avoid this bug:
CcorBccfrom the message.to_addrs=...inSMTP.send_message().CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: