X

Set the Content Type Email from Text/Plain to Text/HTML

Snippets by IsItWP

You may find the default content type email as text/plain. You can change the text/plain type to text/HTML to include custom links, code, and more in the email.

Instructions: Add the following code to the functions.php file of your WordPress theme.

function wps_set_content_type(){
    return "text/html";
}
add_filter( 'wp_mail_content_type','wps_set_content_type' );

You may also enjoy effective tips to get more email subscribers today.

Comments   Leave a Reply

  1. I tried this code. But no use of it. Can you please assist me on this regard?

    1. Usefull Code..

  2. nice

  3. It worked for me in using the email users plugin. I had been losing the html when emailing posts but with this it restored it. Thanks

    1. nice glad to hear it!

  4. Is there a way to do this the other way around? Set content type from HTML to plain?

    1. Just in case anybody else is looking for this answer use the code below instead.

      function wps_set_content_type(){
      return “text/plain”;
      }
      add_filter( ‘wp_mail_content_type’,’wps_set_content_type’ );

  5. Allow customers to request real-time information
    about your business via text message, while putting your contact information in
    the customer’s phone for future reference as well as allow you to capture
    customer’s mobile number

  6. George Serradinho January 18, 2012 at 11:02 am

    I used this code, but then when a user requests to reset his password, then the link in the email that gets sent to the user has no link to click on. do you know what the issue could be?

    1. If you are working off your localhost it may have issues using the mail function, try going via ftp.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!