---
**[tickets:#8533] switch python email 'policy' for better line length handling**
**Status:** in-progress
**Milestone:** unreleased
**Created:** Thu Jan 04, 2024 07:31 PM UTC by Dave Brondsema
**Last Updated:** Thu Jan 04, 2024 07:31 PM UTC
**Owner:** Dave Brondsema
If an email has a super long subject header (for example) with no spaces in it,
email delivery can fail. For example `exim` gives `message has lines too long
for transport`
We’ve handled this before:
- in `SMTPClient.sendmail` and
`test_send_email_long_lines_use_quoted_printable` but apparently it doesn’t
split a header if there’s no spaces or other chars to split on
- `encode_email_part` handled it too, and debugging that seems like it works
correctly (setting header charsets) but it still ends up rewritten later in
sendmail, and causes the error
https://docs.python.org/3/library/email.mime.html for MIMEText and
MIMEMultipart extend from Message which has a default policy of compat32
(python 3.2 compatibility, bugs included). Specifying a different policy (or
using EmailMessage perhaps) seems to work better, and maybe we can get rid of
workarounds within our code. See
https://docs.python.org/3/library/email.policy.html in the middle of the page.
SMTP seems best. (SMTPUTF8 sound appealing, but not all mail servers support
utf8)
---
Sent from forge-allura.apache.org because dev@allura.apache.org is subscribed
to https://forge-allura.apache.org/p/allura/tickets/
To unsubscribe from further messages, a project admin can change settings at
https://forge-allura.apache.org/p/allura/admin/tickets/options. Or, if this is
a mailing list, you can unsubscribe from the mailing list.