Skip to content

Conversation

@Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Dec 23, 2025

One of the original goals of moving to a template system for our emails was to support HTML emails. This PR finally implements them.

Each email type now has an additional body.html.j2 template that is used to generate the HTML content for the email. If the HTML_EMAILS_ENABLED environment variable is set to true then the generated emails will contain multipart content with plaintext and HTML content. Once we have verified that this is not causing any issues in production this feature flag can be removed again.

Note that the email templates have intentionally been kept quite basic for now. We can start to extend them once we verified that everything works as intended.

/cc @paolobarbolini

@Turbo87 Turbo87 added the C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works label Dec 23, 2025
@Turbo87 Turbo87 requested a review from a team December 23, 2025 05:36
@Turbo87 Turbo87 force-pushed the html-emails branch 2 times, most recently from a8c7ae1 to 27e3973 Compare December 23, 2025 05:45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very basic, and could create problems with some anti-spam systems which expect a proper HTML document. If I remember correctly even tools like https://www.mail-tester.com pointed this aspect out.

Another basic test I found interesting in the past was to send emails to Fastmail, download the .eml for the message and look for the X-Spam-hits header. This is what it will looks like for a crates.io email from a few weeks ago:

X-Spam-hits: BAYES_40 -0.001, DCC_CHECK 1.1, ME_SENDERREP_HAM -2,
  RCVD_IN_DNSWL_NONE -0.0001, RCVD_IN_MSPIKE_H5 0.001,
  RCVD_IN_MSPIKE_WL 0.001, SPF_HELO_NONE 0.001, SPF_PASS -0.001,
  LANGUAGES en, BAYES_USED user, SA_VERSION 4.0.1

You can then search for the meaning of rules with a negative score or have an LLM explain it to you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very basic, and could create problems with some anti-spam systems which expect a proper HTML document.

interesting. I looked at some of the emails GitHub was sending and they do not seem to use a full HTML structure either, which is why I implemented it this way 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly even tools like https://www.mail-tester.com pointed this aspect out.

I just ran a quick test and that website appears to be happy with the current state (see https://www.mail-tester.com/test-d5sh981cg).

I used https://htmltest.email/ to send the email to https://www.mail-tester.com, but I assume that shouldn't matter for this specific check?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I guess what I may have seen in the past was a rule in X-Spam-hits penalizing emails with incomplete or broken HTML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-backend ⚙️ C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants