WordPress set mail type to html

//Create function which will return content type

function set_html_content_type() {
     return 'text/html';
 }

//now add filter before wp-mail()

add_filter( 'wp_mail_content_type', 'set_html_content_type' ); // add content filter to html
 wp_mail($to, $subject, $message,$headers);
 remove_filter( 'wp_mail_content_type', 'set_html_content_type' ); // remove content filter

//remove filter after wp_mail()

 

Leave a Reply