每the filter\'s documentation, 这个$content
应格式化以供使用wp_mail()
. 在wp_mail()
documentation, 我发现:
默认字符集基于博客上使用的字符集。可以使用wp_mail_charset
滤器
因此,您似乎需要明确允许WordPress发送HTML邮件。请参见User Contributed Notes 第节wp_mail_charset
筛选文档。
下面是我如何回答你的问题:
/**
* Filter the mail content type.
*/
function wpse360648_set_html_mail_content_type() {
return \'text/html\';
}
add_filter( \'wp_mail_content_type\', \'wpse360648_set_html_mail_content_type\' );
function wpse360648_user_notification_email( $content, $user_login, $user_email, $key, $meta ) {
$m = "<h1>Thanks for signing up</h1>";
$m .= $content;
return $m;
}
add_filter(\'wpmu_signup_user_notification_email\', \'wpse360648_user_notification_email\', 10, 5);
// Reset content-type to avoid conflicts -- https://core.trac.wordpress.org/ticket/23578
remove_filter( \'wp_mail_content_type\', \'wpse360648_set_html_mail_content_type\' );
(基于代码)
Helen Hou-Sandi)