wordpress: mail html mime type breaks the reset password email

The default content type for email sent through core wp_mail function is plain/text. You can change the default content type to text/html :

...
add_filter( 'wp_mail_content_type', 'set_content_type' );
function set_content_type( $content_type ){
return 'text/html';
}

cf codex

But as it says in codex notes, changing content type breaks reset password email, line breaks will not appear and reset link won’t appear.

To prevent that you can just change mimetype for your own emails and keep text/plain for core mail :

....
add_filter( 'wp_mail_content_type','set_content_type' );
wp_mail( my html messages );
remove_filter( 'wp_mail_content_type','set_content_type' );

Leave a Reply

Your email address will not be published. Required fields are marked *