Make WordPress Core

Opened 4 months ago

Last modified 4 months ago

#59670 new defect (bug)

"Content-Transfer-Encoding" might break when sending multiple mails

Reported by: pluspol's profile pluspol Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.3.2
Component: Mail Keywords: dev-feedback
Focuses: Cc:


When sending multiple non-multipart mails via wp_mail the internal encoding used by PhpMailer doesn't get resetted which may result in mails getting the wrong Content-Transfer-Encoding.

wp_mail('someone@somehost.tld', '8bit', '8büt'); // correctly delivered as 8bit
wp_mail('someone@somehost.tld', '7bit', '7bit'); // correctly delivered as 7bit but breaks the following mails
wp_mail('someone@somehost.tld', '8bit', '8büt'); // incorrectly delivered as 7bit

Internally PhpMailer starts with 8bit encoding in $phpMailer->Encoding. When sending a mail it might get downgraded/changed to 7bit in case the message doesn't contain any 8bit chars (which is the case in the first mail).

However because of WP reusing the same PhpMailer instance the encoding doesn't get resetted to 8bit back again and therefore stays at 7bit.

The easiest solution would be resetting the encoding manually or using an appropriate PhpMailer method if existing.
Another solution would be for PhpMailer to be able to upgrade the encoding back to 8bit again when detecting 8bit chars.
IMHO this depends on whether one PhpMailer instance is intended to be used for multiple mails or not.


Change History (3)

#1 @pluspol
4 months ago

This issue triggers the SpamAssassin rule CTE_8BIT_MISMATCH "Header says 7bits but body disagrees".


This ticket was mentioned in Slack in #core-test by ankit-k-gupta. View the logs.

4 months ago

#3 @Ankit K Gupta
4 months ago

  • Keywords dev-feedback added
Note: See TracTickets for help on using tickets.