Plain text instead of HTML

Created on 2 August 2023, over 1 year ago
Updated 4 August 2023, over 1 year ago

I was having an issue with webforms. Email answers once worked OK with HTML bodies, but one day it turned out in the received messages plain HTML code was arriving, not rendered by the browser. I asked for help with an issue at the URL below.

https://www.drupal.org/project/webform/issues/3359386 🐛 HTML in email responses is not rendered anymore Closed: duplicate

I was suggested to try an alternative email handling module - at least this is what I understood - and I eventually came across Mime Mail.

I've just tried Mime Mail on a development drupal instance, with the default configuration. Curiously enough what I receive now via mail is not a message in HTML format, but a plain text where instead of bold characters I see text within a couple of asterisk characters, besides a HTML unordered list is displayed with plain text asterisk characters.

What's going on?

Thanks in advance!

Andrea

🐛 Bug report
Status

Fixed

Component

Miscellaneous

Created by

🇮🇹Italy AppLEaDaY

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @AppLEaDaY
  • 🇺🇸United States tr Cascadia

    I looked at the other issue you posted to see what was going on.
    Thank you for attaching the raw message including headers to that issue - those hold the key to the problem.
    What I see in your message headers is this:

    Subject: Conferma richiesta informazioni su SINFI
    MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8Bit X-Mailer: Drupal Sender: info@innovazioniperlaterra.org From: "In-TIME S.r.l. - Richiesta informazioni su SINFI"
      <info@innovazioniperlaterra.org> Reply-to: "In-TIME S.r.l. - Richiesta informazioni su SINFI"
      <info@innovazioniperlaterra.org> Cc: info@innovazioniperlaterra.org

    You can see that these headers are all wrapped on to one line.
    The problem is that recipient email program can only see the "Subject" header and the "MIME-Version" header because headers are recognized only when the appear at the beginning of a line. When the lines are wrapped like this the recipient does not see "Content-Type: text/html" and doesn't know that the body of the email is supposed to be HTML.

    The headers in your message SHOULD look like this:

    Subject: Conferma richiesta informazioni su SINFI
    MIME-Version: 1.0
    Content-Type: text/html; charset=UTF-8; format=flowed
    Content-Transfer-Encoding: 8Bit X-Mailer: Drupal
    Sender: info@innovazioniperlaterra.org
    From: "In-TIME S.r.l. - Richiesta informazioni su SINFI" <info@innovazioniperlaterra.org>
    Reply-to: "In-TIME S.r.l. - Richiesta informazioni su SINFI" <info@innovazioniperlaterra.org>
    Cc: info@innovazioniperlaterra.org

    Here you can see that each header has its own line, so the recipient can see the "Content-Type: text/html" header and knows that the body is HTML.

    This problem is caused by core Drupal, which is why it affected both Webform and Mime Mail. The issue is discussed in 🐛 PhpMail : broken mail headers in PHP 8.0+ because of LF characters Fixed . It has been fixed in core for several weeks, but I haven't tested it yet.

    Make sure you are using the latest version of Drupal core, which is 9.5.10, because previous versions do not have this fix.

  • 🇮🇹Italy AppLEaDaY

    Many thanks, TR! Your contribution was providential.

  • Status changed to Fixed over 1 year ago
  • 🇺🇸United States tr Cascadia
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024