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

Disable Template if message contains a specific string

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

4 thoughts on “Disable WP-HTML-Mail template for specific emails”

  1. 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

    1. 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 )

  2. Hi Hannes,
    If i try write multiple stripos() joined by || (like in your prior reply), I get an error in my PHP. How would I add 3 more subjects to this code?

    //html email template
    add_filter( ‘haet_mail_use_template’, ‘customize_template_usage’, 10, 2 );
    function customize_template_usage( $use_template, $mail ){
    if( strpos( $mail[‘subject’], ‘Hartelijk dank voor je bericht’ ) !== false )
    return true;
    else
    return false;
    }

Leave a Reply

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