[wp-trac] [WordPress Trac] #53906: wp_mail_content_type doesn't work with pluggable function wp_mail
WordPress Trac
noreply at wordpress.org
Tue Aug 10 11:14:11 UTC 2021
#53906: wp_mail_content_type doesn't work with pluggable function wp_mail
--------------------------+------------------------------
Reporter: skarabeq | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Mail | Version: 5.8
Severity: minor | Resolution:
Keywords: close | Focuses:
--------------------------+------------------------------
Changes (by SergeyBiryukov):
* keywords: => close
Comment:
Hi there, welcome back to WordPress Trac! Thanks for the report.
Setting the type to `text/html` using the `wp_mail_content_type` filter
changes the `Content-Type` header of the email, but does not perform
anything else to actually convert the message to HTML, you still need to
do that yourself.
> When this plugin is active and I have to try to reset my password I have
the following text into a variable `$message`
If you look at the page source at that point, you'll notice that even
though the browser renders the message as a single line, it actually
consists of multiple lines in text format,
{{{
string(362) "Someone has requested a password reset for the following
account:
Site Name: WordPress Trunk (dev)
Username: admin
If this was a mistake, ignore this email and nothing will happen.
To reset your password, visit the following address:
http://develop.wordpress.test/build/wp-
login.php?action=rp&key=...&login=admin&wp_lang=en_US
"
}}}
So you'll need to run something like `nlbr()` to convert it to HTML:
{{{
if ( ! function_exists( 'wp_mail' ) ) {
function wp_mail( $to, $subject, $message, $headers = '',
$attachments = [] )
{
$message = nl2br( $message );
var_dump( $message );
}
}
}}}
which would then result in:
{{{
string(434) "Someone has requested a password reset for the following
account:<br />
<br />
Site Name: WordPress Trunk (dev)<br />
<br />
Username: admin<br />
<br />
If this was a mistake, ignore this email and nothing will happen.<br />
<br />
To reset your password, visit the following address:<br />
<br />
http://develop.wordpress.test/build/wp-
login.php?action=rp&key=...&login=admin&wp_lang=en_US<br />
<br />
}}}
> In WordPress 5.7.2 it is the same, but the URL is with strange brackets
- `<http://local-env.dev/wp-
login.php?action=rp&key=...&login=exampleUser&wp_lang=en_US>`
The brackets were removed in [47086] / #44589 for WordPress 5.4.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53906#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list