#39775 closed defect (bug) (duplicate)
wp_mail miss send Content-Type with boundary when array header does not have other custom headers
| Reported by: | kn007 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Version: | ||
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
It's a PR send in github. https://github.com/WordPress/WordPress/pull/273
Fix empty charset in line 436.
Before:
Content-Type: multipart/alternative; charset=
After:
Content-Type: multipart/alternative; charset=UTF-8
fix $headers[] = "Content-Type: multipart/alternative; boundary=\"$boundary\""; not send when not other headers.
Test Code:
<?php $boundary = md5( uniqid() . microtime() ); $to = 'wordpress@wordpress.org'; $subject = 'TEST'; $headers[] = "From: Wordpress <wordpress@wordpress.org>"; $headers[] = "Content-Type: multipart/alternative; boundary=\"$boundary\""; $body = "--$boundary\r\n" . "Content-Type: text/plain; charset=UTF-8\r\n"; $body .= 'test'; $body .= "--$boundary\r\n" . "Content-Type: text/html; charset=UTF-8\r\n"; $body .= '<div>test</div>'; wp_mail( $to, $subject, $body, $headers );
I could search some issue for this, like
http://wordpress.stackexchange.com/questions/191923/sending-multipart-text-html-emails-via-wp-mail-will-likely-get-your-domain-b
https://wordpress.org/support/topic/using-wp_mail-with-php-generated-attachments/
but still have same problem here.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)


It's not being ignored by
wp_mailbut by PHPMailer. When setting custom headers, theboundaryis removed as it fallback as a regularplainemail.Already reported upstream, and this has become essentially a duplicate of #15448
When we sort out the multipart problem, this will be sorted also. I hope we can achieve this before 6.9 release. Stay tuned to the other report.