Skip to main content

Default to CRLF policy for compat32 emails

This is a minimal package. It patches the standard lib, so that it defaults to using \r\n as line endings, instead of the standard lib default \n.

Doing so makes emitted emails standards compliant.

Moreover, doing so avoids getting corrupted emails delivered when relaying emails via outlook.com or office365.com.

The problem this package fixes, shows up as quoted-printable soft line endings =\n getting transformed into encoded equals signs =3D plus the removal of the first character following the newline. If you have URLs straddling a newline, those will not be valid anymore. But also normal text gets broken.

Email policies

We patch the Compat32 policy class and its compat32 instance. There are other policies, like the EmailPolicy class (using \n as line separator) and its SMTP instance (using \r\n as line separator). We do not touch those.

Quoting from the email.policy documentation:

  • There is a default policy used by all classes in the email package. For all of the parser classes and the related convenience functions, and for the Message class, this is the Compat32 policy, via its corresponding pre-defined instance compat32. This policy provides for complete backward compatibility (in some cases, including bug compatibility) with the pre-Python3.3 version of the email package.

  • The default value for the policy keyword to EmailMessage is the EmailPolicy policy, via its pre-defined instance default.

Why patch the standard lib, instead of fixing your own code?

Because to fix your own code, you’d have to ensure to override the default policy in every single instantiation of every Message or MIMEText or any of the other constructors which default to the compat32 policy without carriage returns.

Instead, you now can simply add emailcompat32crlf to your project dependencies and import it. Done.

If you are using Plone: we register an autoinclude entry point, so you do not even need to import it.

Changelog

1.0.3 (2024-06-03)

  • Register z3c.autoinclude.plugin entry point for Plone. This imports the package automatically on startup. This entry point is ignored when you don’t use Plone.

1.0.2 (2024-05-31)

  • Fix possible import error.

1.0.1 (2024-05-31)

  • Fix several problems in initial release.

1.0.0 (2024-05-31)

  • Initial release.

Metadata

Release files for emailcompat32crlf 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for emailcompat32crlf 1.0.3
File Size Uploaded
emailcompat32crlf-1.0.3.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for emailcompat32crlf 1.0.3
File Interpreter ABI Platform
emailcompat32crlf-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.4 kB

Release files / emailcompat32crlf-1.0.3.tar.gz

Download URL emailcompat32crlf-1.0.3.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
79232f1302e8a29613ec1b2549e03db6b935a4a43088026c459a3390961c9437
BLAKE2b-256 checksum
How to use checksums
56eb699dd63887e0509398c5f73a107882745ec1b32a492d5d83fb0d3c4bba25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / emailcompat32crlf-1.0.3-py3-none-any.whl

Download URL emailcompat32crlf-1.0.3-py3-none-any.whl
Size 3.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37708094bf8aaeb2f2445229524580682d4ba1a1a6e7e9eb60f90a5a27031b4b
BLAKE2b-256 checksum
How to use checksums
70e6e6fd3ac7d3b67d285993efe803d26ce52461da3c7feb34c0e3c3962d15ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page