How to Send HTML Emails From WordPress

How to Send HTML Emails From WordPress Using wp_mail Function

How to Send HTML Emails From WordPress Using wp_mail Function.
Yes you can use WordPress’s wp_mail() function to send HTML emails from your WordPress site. However, the default content type of wp_mail() function is set to ‘text/plain’ which does not allowed you to send HTML in emails. If you want to send HTML emails using the WordPress wp_mail() function then you will need to set the content type of the email to “text/html” by using the ‘wp_mail_content_type’ filter. This is how you can do that:

Before you send your wp_mail() call add a filter to wp_mail_content_type. You can add this filter which is shown below.

Then create a function set_content_type and in that function have to return the appropriate content type, in this case it is ‘text/html’. See below

Another Way to Set the Mail Content Type to HTML

I’m a web developer / PHP programmer. I am also working on custom plugin development of wordpress.