WP HTML Mail Documentation


By loading the video, you agree to YouTube's privacy policy.
Learn more

Load video

Can I send my newsletter campaigns with this plugin?

No, this is not a newsletter tool, it just makes your emails beautiful but doesn’t send custom ones.

How can I remove the gap at the header of my Contact Form 7 emails?

Go to your Contact Form 7 email settings and change email type from HTML to text. WP HTML Mail will take care of the HTML.

Can a customize the HTML code of the email header?

There’s a filter to change the header HTML code. Just add this to your (child-)themes functions.php:

add_filter('haet_mail_header', function( $header ){
  return 'hello <strong>world</strong>';

Of course you can display HTML code, not just text.

Can I add custom CSS code to my WordPress emails?

You can add your own CSS code for desktop and mobile. Just add this example to your (child-)themes functions.php and customize it:

add_filter( 'haet_mail_css_desktop', function( $css ){
    $css.= ' h1{ border-bottom: 2px solid green; } ';
    return $css;
add_filter( 'haet_mail_css_mobile', function( $css ){
    $css .= ' h1{ background:red; } ';
    return $css;

Add a rounded border around your email content.

Another example of custom CSS, but not all email clients support rounded corners. In most versions of Microsoft Outlook you will only see regular border with edges.

add_filter( 'haet_mail_css_desktop', function( $css ){
    $css .= '  
            	border: 1px solid #ddd;
            	border-bottom: none;
            	border-top-left-radius: 10px;
            	border-top-right-radius: 10px;
            	border: 1px solid #ddd;
            	border-top: none;
            	border-bottom: none
            	border: 1px solid #ddd;
            	border-top: none;
            	border-bottom-left-radius: 10px;
            	border-bottom-right-radius: 10px;
    return $css;


How can I modify the text shown in short email preview in some mail clients?

Add the following lines of code to your themes functions.php

add_filter( 'haet_mail_preheader', function( $pre_header, $email ){
  return 'this is my custom preheader';
}, 10, 2 );

If you want to remove the pre-header:


How to disable the template for some emails?

Find anything all emails hav in common. It may be the sender, a word in the subject or something in the email body.
Then add this function to your (child-)themes functions.php and customize it. Return TRUE if the template should be used and FALSE if not.

// return true if you want to use a template for current mail
// return false if you want to leave the content of this email unchanged
add_filter( 'haet_mail_use_template',
  function ( $use_template, $mail ){
  // $mail['to'] ...
  // $mail['subject'] ...
  // $mail['message'] ...
  // $mail['headers'] ...
  // $mail['attachments'] ...
  return true;
}, 10, 2 );

In detail: Let’s assume all emails from plugin X contain the word “foo” in subject:

add_filter( 'haet_mail_use_template', 
  function ( $use_template, $mail ){ 
    // find the string "foo" in subject
    if( stripos( $mail['subject'], 'foo' ) !== false )
      return false;
    // otherwise do not change
    return $use_template;
  , 10, 2