Email Users with WP Better Emails

I recently worked with a user who reported Email Users wasn’t working correctly in conjunction with the WP Better Emails plugin.  The user posted a code sample he had used to correct the problem.

Looking at the code sample and his description of what WP Better Emails expected to receive as input, I added a new filter, mailusers_html_wrapper, that when present, would not add the default HTML wrapper around the email content but instead would expect the filter to perform the desired operation.  This new filter was released in the 4.7.2 version of Email Users.  There is an example usage of the new filter in my post announcing Email Users 4.7.2.

Shortly after releasing 4.7.2 I was contacted by the user again letting me know the filter didn’t solve the problem.  Confused, I download WP Better Emails to try and figure out what could possibly be wrong.  It took me the better part of two hours to trace through the WPBE code and figure out what it is doing – it turns out, WPBE wants emails to be “plain text” and not HTML formatted.  This is counter intuitive and had me looking in the wrong place for quite while.  It seems backwards to me but that is how the WPBE plugin works.

So how to make WPBE work with Email Users?  It turns out, it isn’t that hard at all.  There is a WordPress filter, wp_mail_content_type, which influences wp_mail(), the function WordPress uses to send email.

If a wp_mail_content_type filter is defined to force the content type to “text/plain”, Email Users and WPBE will work together correctly.  Below is the filter I defined and tested the interaction of Email Users and WPBE with.  Place this filter in your theme’s functions.php file or somewhere else where it will be loaded.

add_filter( 'wp_mail_content_type', 'mailusers_set_content_type' );
function mailusers_set_content_type( $content_type ) {
return 'text/plain';

6 thoughts on “Email Users with WP Better Emails

  1. Hi,

    this is farhan, I am using your plug-in “email to user”. First of all I would like to say thanks for this plug-in, it is excellent plug-in. This plug-in fulfill my retirement.
    I am facing a problem using this plug-in. I am unable to send email to multiple users. As per configuration guide I have setup BCC limit 30 for sending email to multiple users. But unfortunately it is not working. Please tell me how can I resolve this issue. Actually this is the only email plug-in which is perfect for my case. I will be grateful to you.


    • It is hard to know for sure how to solve your issue but we can try a couple things. How many users are you trying to mail at one time? Do you know if your hosting provider has any limitations on number of email messages you can send or restrictions on using the BCC field? Do all of your users allow mass email?

      Email Users has a debug feature which allows you to see what the constructed email headers look like. This is a good way to verify that the users you think should be receiving the email are actually added to the header.

      • hi,

        Thanks for the prompt answer. Following are the answer of your questions. I hope the my answers will help to resolve my issue.

        How many users are you trying to mail at one time?
        ANS: I tried to send email to 2 users only. both emails ids are mine and are gmail ids. For testing I did this practice. I receive email on only one id.

        Do you know if your hosting provider has any limitations on number of email messages you can send or restrictions on using the BCC field?
        ANS: I have no idea about this restriction. I tried search about this question could not get proper answer. I am using hostgator (baby plan).

        Do all of your users allow mass email?
        I have no idea. How would I know that?


  2. Amen. This tiny code in my functions.php file did the trick for me. Thank you for putting this out there. There doesn’t seem to be much conversation around this topic on many sites. Thank you.

Leave a Reply to Mike Walsh Cancel reply