• Resolved wallifantastic

    (@wallifantastic)


    WP HTML Mail does exactly what it is supposed to do. It wraps the styling around the email content. But if you send emails via Mail Queue Plugin or if you resend emails via WP Mail SMTP it again wraps the styling around the email. So we’re wondering if we can disable WP HTML Mail for emails that are already html styled mails. Or in other words: Can we just activate WP HTML Mail if the email to be sent is just in plain/text format. We found this in your FAQ: https://codemiq.com/en/support/wp-html-mail-documentation/ That looks promising.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter wallifantastic

    (@wallifantastic)

    Maybe it’s possible to check if Content-Type is text/html.

    add_filter( 'haet_mail_use_template', function ( $use_template, $mail ){
    // find the Content-Type "text/html" in headers
    if( $mail['headers'] ... )
    return false;
    // otherwise do not change
    return $use_template; } , 10, 2 );

    hey @wallifantastic

    checking the content type will not work. Many emails are already HTML although they do not look formatted.

    I currently think about checking the content of the mail for specific classes and only apply the template if the class is not already present.

    you can try with the filter you mentioned above if you need a fast solution. Otherwise it seems like a good idea to add this feature to the plugin within the next days.

    best regards Hannes

    Thread Starter wallifantastic

    (@wallifantastic)

    Hey Hannes, thank you for your quick reply. In principle, we need to identify those emails whose content has already been provided using the WP HTML Mail Template. I just saw, that we can create our own template file. In this file we could add a class=”my-template” to the body tag. Then we could do something like this:

    add_filter( 'haet_mail_use_template', function ( $use_template, $mail ){
    if( $mail['message'] ...CONTAINS BODY CLASS "my-template"... )
    return false;
    return $use_template;
    } , 10, 2 );

    Unfortunately I’m not a programmer. Could you help us with that code?

    Thread Starter wallifantastic

    (@wallifantastic)

    Dear Hannes, do you think, we’re on the right track with this approach? Thank you so much for your support!!!

    Plugin Support Julian

    (@juliangk)

    Hello @wallifantastic,

    please try this code:

    add_filter( 'haet_mail_use_template', 'customize_template_usage', 10, 2 ); function customize_template_usage( $use_template, $mail ){ if( strpos($mail['message'], 'CONTAINS BODY CLASS') ){ return false; } return true; }

    Best regards
    Julian

    • This reply was modified 1 year, 3 months ago by Julian.
    Thread Starter wallifantastic

    (@wallifantastic)

    Hi Julian, thank you so much!!! That did the trick. Now we can resend the mails and queue them, without wrapping them into the email template a second time. This is probably interesting for other users as well. So maybe it’s worth to write a small faq on your documentation page. Kind regards, and thank you again!!!

    Plugin Support Julian

    (@juliangk)

    Hello @wallifantastic,

    you are most welcome. I am happy it’s working now.
    Please let us know if you need anything else.

    Best regards
    Julian

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Email contains duplicate header and footer when it is resent or sent via queue’ is closed to new replies.