I have a plugin which has its own register facility. This is on a multisite. I am using a must use plugin to send a custom activation email. This is the activation email which the user has to click in order to activate their account.

I am using the wpmu_signup_user_notification_email hook to catch the email and change the content. This is working, but the email is not html - any html such as header tags and paragraphs and br's are just included in the text.

How can I make this send a html based email.

Thank you

function my_signup_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', 'my_signup_user_notification_email', 10, 5);

1 Answer 1


Per the filter's documentation, the $content should be formatted for use by wp_mail(). In the wp_mail() documentation, I find this:

The default charset is based on the charset used on the blog. The charset can be set using the wp_mail_charset filter.

So it appears you need to explicitly allow WordPress to send HTML mail. See the User Contributed Notes section of the wp_mail_charset filter documentation.

Here's how I'd tackle your question:

 * 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' );

(based on code by Helen Hou-Sandi)

  • Thanks so much. I had to remove the remove_filter though, otherwise it didn't work - I assume because it is being removed before actually sending the email. I hope this doesn't have any negative effects. Mar 13, 2020 at 16:11
  • Yeah, that could be the case. If I read the Trac ticket correctly, the issue is that HTML emails, of course, have <> characters in them, and that might interfere with URLs being sent in some emails. Looks like there's a fix coming in 5.4, so it hopefully won't be a concern for too long.
    – Pat J
    Mar 13, 2020 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.