Disable WP-HTML-Mail template for specific emails

WP HTML Mail is a free WordPress plugin to customize all your outgoing emails. In most cases the plugin just wraps a container around existing emails and applies some nice styling.

For some plugins like WooCommerce and Easy Digital Downloads it offers advanced styling features.

But many other plugins already use their own template system. WP HTML Mail can’t detect these other templates, but it has a filter to manually disable the template for some emails.

Just add one of the functions below to your themes functions.php

Disable Email Template by subject keyword

add_filter( 'haet_mail_use_template', 'disable_email_template_by_subject', 10, 2 );
function disable_email_template_by_subject( $use_template, $email ){
    if( stripos( $email['subject'], 'MY KEYWORD' ) !== false )
      $use_template = false;
  return $use_template;

Disable Template if message contains a specific string

add_filter( 'haet_mail_use_template', 'disable_email_template_by_message', 10, 2 );
function disable_email_template_by_message( $use_template, $email ){
 if( stripos( $email['message'], 'MY KEYWORD' ) !== false )
      $use_template = false;
  return $use_template;

You can change the functions to use receiver, attachment or anything else to detect your email.

2 Responses to “Disable WP-HTML-Mail template for specific emails”

  1. Daniel Violante

    Hello, im contacting you to know how i can add more than 1 keyword in this code line
    if( stripos( $email[‘message’], ‘MY KEYWORD 1 MY KEYWORD 2 MY KEY WORD 3’ ) !== false )

    I hope you can help me.
    Thank you

    • hannes

      Just write multiple stripos() joined by ||

      if( stripos( $email[‘message’], ‘MY KEYWORD 1’ ) !== false || stripos( $email[‘message’], ‘MY KEYWORD 2’ || stripos( $email[‘message’], ‘MY KEYWORD 3’ ) !== false ) !== false )


Leave a Reply