---
title: "How to send WordPress HTML Email"
url: https://coolplugins.net/how-to-send-wordpress-html-email/
date: 2021-08-25
modified: 2026-05-29
author: "Satinder Singh"
description: "WordPress wp_mail() sends plain text emails, but HTML formatting requires specific configuration changes or filters. wp_mail_content_type filter enables HTML emails but may break default WordPress core email formatting and line breaks. Using wp_mail headers with Content-Type text/html allows custom HTML emails without affecting core email structure. Email templates can be created separately and included in wp_mail for reusable, structured, professional email designs."
categories:
  - "WordPress Tips"
image: https://coolplugins.net/wp-content/uploads/2025/04/send-html-emails-wordpress-site-fimg-800x450.png
word_count: 647
---

# How to send WordPress HTML Email

![Send Wordpress HTML Email](https://coolplugins.net/wp-content/uploads/2021/08/send-wordpress-email.png)

In this Article you will learn to send [WordPress ](https://wordpress.org/)HTML Email. In WordPress emails are sent to the users to keep the users informed. These Emails can be for the registration, comment, product purchase, deals etc. To send users the email you must know how to use the WordPress* **wp_mail() **function* of WordPress.

The wp_mail expects three parameters:

- The email recipient(s)

-  Subject

- Message

When using the* ****wp_mail function* **the message sent to the user is simply plain text. The email might not look fancy but it is quite useful. But what if you want to send a more beautiful message including logo, header, footer instead of simply plain text.

The problem here is when you are creating an email with html tags and inline styling, you may expect your email to render the HTML. But instead of that it will show html tags as plain text. So how to solve this problem and tell wordpress to render the html styling in the email.

**Method 1: Wordpress HTML email using* wp_mail_content_type* filter**

Wordpress provides a filter *wp_mail_content_type* to set email content type to text/html. This filter will automatically render all the html tags and the inline styling in the email content.

**To use this filter :**

Navigate to **Dashboard >> Appearance >> Themes → functions.php,**

And paste the below code

PHPadd_filter( 'wp_mail_content_type', function( $content_type ) {

    return 'text/html';

} );
```
add_filter( 'wp_mail_content_type', function( $content_type ) {

    return 'text/html';

} );
```

Now the email sent through the application are the html emails, it solves the problem of custom email but breaks the formatting of wordpress core emails like forget password, reset password etc.

Wordpress uses the line break in its core emails but after using the ***wp_mail_content_type* **filter the line breaks will not appear in the email.

For example: You have added ***wp_mail_content_type ***filter to your **functions.php **file, then the core email sent to the admin/author will not show any line break.

### Method 2: Wordpress HTML email using wp_mail filter:

If you want that the core email formatting should not break, you have to use the *wp_mail *filter instead of the *wp_mail_content_type* filter.

*wp_mail* filter has the parameter *$header* and this will solve our problem.

You just need to use the $header parameter in your custom code, and it will send the custom HTML email. This parameter has to be sent explicitly in your code.

Your code for Custom email will look like:

PHP<?php

$message = '<h1>Email Heading</h1><p>Email Content</p>';

$headers = array('Content-Type: text/html; charset=UTF-8');

$to = get_option('admin_email');

$subject = "My Email Subject";

$mail = wp_mail($to, $subject, $message, $headers);

?>
```
<?php

$message = '<h1>Email Heading</h1><p>Email Content</p>';

$headers = array('Content-Type: text/html; charset=UTF-8');

$to = get_option('admin_email');

$subject = "My Email Subject";

$mail = wp_mail($to, $subject, $message, $headers);

?>
```

For the $header parameter you have to set the value to text/html, this will be for your custom HTML email.

### Method 3: Using templates:

Assuming you have already created a template design and save it in the templates/email-templates.php file like this:

PHP<!DOCTYPE html PUBLIC "...">

<html xmlns="https://www.w3.org/1999/xhtml">

<head>

  <title><?php echo esc_html( $title ); ?></title>

  <style>...</style>

</head>

<body>

  <p><?php echo $html; ?></p>

  ...

</body>

</html>

You can use the template for Custom email like this:

function send_email($test) {

$email = ‘user@domain.com’;

$title = “Here is the title’;

$html = ‘Here is the content’;

$content = include ‘./templates/templates.php’;

wp_mail($email, $title, $content); }
```
<!DOCTYPE html PUBLIC "...">

<html xmlns="https://www.w3.org/1999/xhtml">

<head>

  <title><?php echo esc_html( $title ); ?></title>

  <style>...</style>

</head>

<body>

  <p><?php echo $html; ?></p>

  ...

</body>

</html>

You can use the template for Custom email like this:

function send_email($test) {

$email = ‘user@domain.com’;

$title = “Here is the title’;

$html = ‘Here is the content’;

$content = include ‘./templates/templates.php’;

wp_mail($email, $title, $content); }
```

### Extras:

##### Custom email using Plugins:

- *Email Template*

- *Wordpress Email Template designer*

*These are some of the plugins that can help you to create an outline of your template.***