How to send HTML emails from WordPress Using wp_mail function?

WordPress comes with a built-in mail function which allows you to easily send emails from your website. This function is called wp_mail() function. However, all mails sent using the wp_mail() function are of  ‘plain/text’ content type which does not allow HTML in the email. If you need to send a HTML formatted email, you have to change the email’s content type to ‘text/html’. To do this we are going to use wp_mail_content_type filter.

To change the content type to HTML paste the following code in your theme’s functions.php file.

//Send HTML emails in WordPress Using wp_mail function
add_filter( 'wp_mail_content_type', 'set_content_type' );
function set_content_type( $content_type ){
	return 'text/html';

Useful Read: Redirect All 404 Errors In WordPress To Home Page


Leave a Comment.