Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable option to skip base64 encoding of headers with pure ASCII characters #71

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

samwan-loops
Copy link

@samwan-loops samwan-loops commented Sep 6, 2024

Problem: Spam detection servers such as rspamd consider certain Base64-encoded headers to be red flags, and increases the spam score of emails with such headers. By default, MIMEText will applies base64 encoding to all headers, which means that emails encoded with the MIMEText library will have higher spam scores by default.

Proposal: Provide an optional flag in EnvironmentContext to skip base64 encoding for a header if it contains only ascii characters. Since this flag is optional, there is no breaking change.

Approach:

  • Add an optional skipEncodingPureAsciiHeaders flag to EnvironmentContext to skip encoding headers with pure ASCII values.
  • Add a helper function optionallySkipPureAsciiEncoding to MIMEMessageHeader to detect whether a value is pure ASCII, and skip encoding it if the option is enabled.
  • Use this helper function in headers that use dumpMailboxMulti or dumpMailboxSingle, and for the Subject header.
  • Update the MIMEMessageHeader.spec.js unit test to cover encoding headers with non-ascii characters, and optionally encoding headers with ascii-only characters.

Comment: There are some unit tests not passing, but they are not passing in the main branch and do not seem to be due to the changes in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant