Wordpress - Is there a way to send HTML formatted emails with WordPress' wp_mail() function?
As an alternative, you can specify the Content-Type HTTP header in the $headers parameter:
$to = '[email protected]';
$subject = 'The subject';
$body = 'The email body content';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers );
from wp_mail codex page:
The default content type is 'text/plain' which does not allow using HTML. However, you can set the content type of the email by using the 'wp_mail_content_type' filter.
// In theme's functions.php or plug-in code:
function wpse27856_set_content_type(){
return "text/html";
}
add_filter( 'wp_mail_content_type','wpse27856_set_content_type' );
Don't forget to remove the content type filter after you use the wp_mail function. Following the accepted answer naming you should do this after wp_mail is executed:
remove_filter( 'wp_mail_content_type','wpse27856_set_content_type' );
Check this ticket here - Reset content-type to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578