Make WordPress Core

Opened 2 years ago

Closed 6 months ago

Last modified 6 months ago

#59670 closed defect (bug) (duplicate)

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

Reported by: pluspol's profile pluspol Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.3.2
Component: Mail Keywords:
Focuses: Cc:

Description

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.

See:

Change History (5)

#1 @pluspol
2 years ago

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

See: https://svn.apache.org/repos/asf/spamassassin/tags/sa-update_3.4.4_20200729083044/rulesrc/sandbox/davej/20_non_ascii.cf

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


2 years ago

#3 @Ankit K Gupta
2 years ago

  • Keywords dev-feedback added

#4 @SirLouen
6 months ago

  • Resolution set to duplicate
  • Status changed from new to closed

Yes, this has already been reported here #33972

Closing for duplicate.

#5 @desrosj
6 months ago

  • Keywords dev-feedback removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.