Mail HTML to TXT causes DKIM failure

Created on 19 December 2018, almost 6 years ago
Updated 21 April 2024, 5 months ago

Problem/Motivation

DKIM fails because the mail body gets altered, in more detail:

  • During the conversion of HTML to Plain Text (drupal_html_to_text), the h3 and h4 tags are prefixed by ".... " and ".. " respectively.
  • SMTP uses dot-stuffing (see https://tools.ietf.org/html/rfc5321#section-4.5.2 for details) which alters the prefixes of the h3 and h4 plain text conversions.
  • By altering these prefixes, the mail body gets altered and consequently, DKIM verification fails.

I haven't tested it, but I expect the same issue exists in Drupal 8 with the MailFormatHelper in Drupal\Core\Mail.

Context:

SMTP uses a single period (dot) at the beginning of a separate line to denote the end of a mail message. Because users are not expected to be aware of this, SMTP adds an additional period (dot) before each dot on a separate line when it occurs in the message body, before sending the message.
Then DKIM signature is constructed on the mail body, including the additional period added by SMTP.
When the message is received, the receivers SMTP removes the added dots to reconstruct the original message. It thereby alters the mail body which causes the DKIM verification to fail with the error: Mail body has been altered.

Steps to reproduce

Proposed resolution

Use some other prefix instead of the series of dots.

Remaining tasks

  1. Create MR
  2. Review
  3. Commit

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Mail 

Last updated about 12 hours ago

No maintainer
Created by

🇳🇱Netherlands INAScon

Live updates comments and jobs are added and updated live.
  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024