PressTigers

How to change Content Type in wp_mail Function

All emails in WordPress are sent using the function wp_mail. The default content type for these emails is “text/plain” that does not allow HTML to be placed in them (emails). If you want to create custom HTML emails, you need to change the default content type of your emails from “text/plain” to “text/html“.

For instance if you being an administrator want to send a promotional email about your products to all registered users, you may want to embed an image such as a logo included in your signature via wp_mail() function in it. For this, HTML formatted email (text/html) is required. For setting up that email, simply add a filter to wp_mail_content_type.

Following given code will change the default content type of wp_mail function from “text/plain” to “text/html“:

Although other MIME types are available too but “plain text” and “HTML” are the most common among them.

User Comments

Leave a Reply

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

    Get in Touch