What's Changed
- Security: reject addresses containing whitespace or angle brackets outside of a
quoted local part inmail,rcpt,vrfy,expnandsendmail.
Previously, a caller supplied address such as
user@example.com> AUTH=<attacker@example.comcould smuggle additional ESMTP
parameters onto the command line. This is a follow up to the fix in 5.1.1 for
CVE-2026-53533 (GHSA-v3q9-hj7j-63hq), which only rejected control characters.
sendmailnow validates all addresses before sending any commands. - Bugfix: reject
local_hostnamevalues (and thehostnameargument to
helo/ehlo) containing whitespace or control characters, so a hostname
such asme.example.com XCLIENT ADDR=1.2.3.4can no longer smuggle extra
parameters onto the EHLO/HELO command line. Surrounding whitespace is stripped. - Bugfix: raise
SMTPAuthenticationErrorinstead ofbinascii.Errorwhen the
server sends a malformed (non-base64) CRAM-MD5 challenge, sologincan fall
back to the next auth method - Bugfix: prevent SMTP command/response desync from unsolicited server data (thanks
@Charisn for contributing) - Bugfix: handle protocol connection lost callback arriving after reconnect
- Bugfix: close connection on async context manager exit in cases of a server error response
- Bugfix: release connection lock on connect timeout
- Bugfix: re-derive the default port on each
connect()so changing
use_tls/start_tlsbetween connects no longer reuses a stale default.
Defaultedport/hostnameare now resolved per-connect rather than
written back onto the instance, so they read back asNonewhen unset - Bugfix: typeerror in latest ty
- Bugfix: mark response waiter exceptions as retrieved when they are set, so
Future exception was never retrievedis no longer logged on free-threaded
builds where the previous__del__based cleanup ran too late - CI: test on free-threaded 3.14 and on 3.15 (standard and free-threaded)
- Bugfix: the
SIZEparameter sent withMAIL FROMnow reports the number
of octets as the message will be transmitted (with CRLF line endings), rather
than the raw length of the message argument - Bugfix: data arriving on the transport after the connection is lost is now
dropped instead of raisingRuntimeErrorfrom the protocol callback - Bugfix:
SMTPProtocolnow records that it is using TLS after a successful
start_tls, so a second upgrade attempt on the protocol is rejected - Bugfix:
starttlsnow validates its TLS options before sending EHLO, so
invalid options raiseValueErrorwithout touching the connection - Bugfix:
helono longer records a failed response aslast_helo_response,
so a rejected HELO does not leave the session looking as if a greeting succeeded - Bugfix:
bytearrayandmemoryviewvalues are no longer silently passed
through the auth encoding helpers; onlystrandbytesare accepted, as
the type annotations already stated - Bugfix: TLS context setup now run in thread (thanks @tr4nt0r)
New Contributors
Full Changelog: v5.1.2...v5.1.3