Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#31566 closed defect (bug) (invalid)

Non-ASCII characters corrupted in mails sent using wp_mail on some systems

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

Description

A plugin sends mails using the wp_mail function.

This works fine on all systems if ASCII-only characters are used in the message body. However, on one system it fails if non-ASCII characters are contained in the message body. Exactly the same WP version/configuration is used on all WP installs.

I added a wp_mail hook and compared the values passed to wp_mail. They are exactly the same on both systems, see below. The message body contains the German words "Mücke" and "Österreich" (umlauts "ü" and "Ö").

array(5) { ["to"]=> string(16) "info@example.org" ["subject"]=> string(49) "=?utf-8?Q?Webformular:_Nachricht_von_M=C3=BCcke?=" ["message"]=> string(219) "Submitted on: 9. März 2015 Via: /kontakt/ By XXX.XX.XXX.XXX (visitor IP). Name: Mücke E-Mail-Adresse: info@example.org Ihre Nachricht: Österreich " ["headers"]=> array(8) { [0]=> string(36) "Date: Sun, 8 Mar 2015 22:28:52 +0000" [1]=> string(46) "From: "info@example.org" " [2]=> string(0) "" [3]=> string(0) "" [4]=> string(26) "Reply-to: info@example.org" [5]=> string(13) "X-Priority: 3" [6]=> string(17) "MIME-Version: 1.0" [7]=> string(72) "Content-Transfer-Encoding: 8bitContent-Type: text/plain; charset="utf-8"" } ["attachments"]=> array(0) { } }

This mail is received when wp_mail is called with the above values on some WP installs:

[...]
X-Mailer: PHPMailer 5.2.7 (https://github.com/PHPMailer/PHPMailer/)
[...]
MIME-Version: 1.0
Content-Transfer-Encoding: 8bitContent-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[...]

Name: Mücke
E-mail: info@example.org
Message: Österreich

Decoding works just fine and leads to a result containg the German workds "Mücke" and "Österreich".

However, on one WP system the resulting mail looks like this:

[...]
X-Mailer: PHPMailer 5.2.7 (https://github.com/PHPMailer/PHPMailer/)
[...]
MIME-Version: 1.0
Content-Transfer-Encoding: 8bitContent-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

[...]

Name: M=C3=BCcke
E-mail: test@example.org
Message: =C3=96sterreich

Thunderbird and Roundcube are not able to decode this mail. The mail displayed in the mail clients contains the undecoded words "M=C3=BCcke" and "=C3=96sterreich".

Why is 'Content-Transfer-Encoding: quoted-printable' used on one system?

Potential sources of the problem:

  • Something in the server's PHPMailer configuration is wrong. Which config does WP expect? What has to be changed?
  • wp_mail is passing the wrong arguments to PHPMailer.

Change History (2)

#1 @codifex
10 years ago

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

It seems that the problem was caused because two headers were not separated correctly ("8bitContent"). Separating them seems to solve the problem.

[7]=> string(72) "Content-Transfer-Encoding: 8bitContent-Type: text/plain; charset="utf-8"" } ["attachments"]=> array(0) { } }

#2 @SergeyBiryukov
10 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.