D7.100 and php8.2 with mimemail failing to display html

Created on 17 July 2024, 4 months ago
Updated 23 July 2024, 4 months ago

I updated a D7 site to use php8.2 (required because of encryption issues for SagePay with php 7) and it mostly works, but I have a weird issue with Commerce email notifications. It is set to use mimemail for html emails and worked fine under php 7.4.

The emails show in plain text this at the start:

This is a multi-part message in MIME format.

--43d3c19221c7c3a23b01b8168a773d2eb4c4486b7
Content-Type: multipart/alternative;
 boundary="2a221e989dcd4438c1d7c69cf939c81049db83376"
Content-Transfer-Encoding: 8bit

--2a221e989dcd4438c1d7c69cf939c81049db83376
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

and then at the end of the email this:

Content-Type: text/html; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: base64

DQo8IURPQ1RZUEUgaHRtbCBQVUJMSUMgIi0vL1czQy8vRFREIFhIVE1MIDEuMCBTdHJpY3QvL0VO
IiAiaHR0cDovL3d3dy53My5vcmcvVFIveGh0bWwxL0RURC94aHRtbDEtc3RyaWN0LmR0ZCI+DQo8
aHRtbCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCI+DQogICAgPGhlYWQ+DQog
.....

Has anyone come across this issue and perhaps knows how to fix it?

Thanks
Martin

πŸ’¬ Support request
Status

Postponed: needs info

Version

1.2

Component

Miscellaneous

Created by

πŸ‡¬πŸ‡§United Kingdom nattyweb

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

Comments & Activities

  • Issue created by @nattyweb
  • Status changed to Postponed: needs info 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    Almost certainly this is due to bad message headers. Please attach a text file with your unformatted raw message headers.

    #3261886: html tags not interpreted β†’
    πŸ› PhpMail : broken mail headers in PHP 8.0+ because of LF characters Fixed

    In short though, Drupal core changes line terminators in the headers to try to fix and avoid long-standing problems with PHP using the wrong line terminators, but in PHP 8.2 this got changed. I know we fixed this in Drupal core 9+ a long time ago but I don't know about D7...

  • πŸ‡¬πŸ‡§United Kingdom nattyweb

    Thanks for a reply @TR! Revealed code from the first part of the email attached (I assume this is what you're after?).

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    Yes, that's what I was looking for. This is the problem I thought.

    I did a search and found it was never fixed in core Drupal 7. See πŸ› [D7] PhpMail : broken mail headers in PHP 8.0+ because of LF characters Needs work . There's a patch in that issue which should fix the problem for you

  • πŸ‡¬πŸ‡§United Kingdom nattyweb

    Many thanks @TR. I applied the patch to fix the issue, but it turns out it was caused by a faulty mimemail template in the theme folder. Long story short, I am switching back to php 7.4 as there seems to be fewer issues with the several custom modules I inherited.
    I appreciate the suggested fix though - thank you.
    Martin

Production build 0.71.5 2024