wp_mail() sets Content-Type header twice for multipart emails
|Reported by:||rmccue||Owned by:||nacin|
|Component:||Keywords:||gci has-patch westi-likes needs-refresh|
When trying to send emails via wp_mail() with a Content-Type of multipart/alternative, the Content-Type header will be set with $phpmailer->ContentType, and again with $phpmailer->AddCustomHeader(), which causes two Content-Type headers in the email:
Content-Type: multipart/alternative; boundary="example_boundary" Content-Type: multipart/alternative; charset=""
This appears to cause errors in Outlook, as there is no boundary on the latter.
The cause of this is PHPMailer::GetMailMIME(), as it does not know that the email is a multipart email. The easiest way to achieve this appears to be to simply allow the user to set the AltBody via wp_mail(). In order to achieve backwards compatibility, wp_mail() should work out which part is the text/plain one and which is the text/html one based on the boundary.
I'll be working on a patch for this.
Change History (33)
comment:13 @westi — 4 years ago
- Milestone changed from Future Release to 3.2
- Owner changed from rmccue to westi
- Status changed from assigned to reviewing
comment:22 @westi — 4 years ago
- Keywords 3.3-early westi-likes added
- Milestone changed from 3.2 to Future Release
comment:27 @rmccue — 2 years ago
- Keywords needs-refresh added; 3.3-early removed
- Milestone changed from Future Release to 3.6
- Owner changed from westi to nacin