Email Users v4.8.0-beta-1 available

Earlier today I released Email Users v4.7.10 which is the formal release of a number of fixes I’ve had in the queue.  Now that it is out, I’ve moved on to the first real new functionality in a while which is why this will be v4.8.x.

Recently there was a 1 Star rated review of Email Users which had a comment about not being able to search for a user in a list of potential recipients.  As you can see in the comments, I didn’t disagree with the user although what they wanted to do was sort of possible.

I’ve used the jQuery Chosen plugin a couple times and it works great for making SELECT elements much more user friendly.  I decided to add it to Email Users to make finding users, particularly for sites which have lots of users, much easier.  If you used WooCommerce, you’re familiar with Chosen as that is what WooCommerce uses for SELECT elements as well.

The v4.8.0-beta-1 release is the first implementation of Email Users with the jQuery Chosen plugin integration.  Please download it, try it out, and report any issues or concerns.

Implementing Chosen allows for easy search and selection as noted in these images.

EU_SS_47

From the Send to User(s) page

EU_SS_48

From the Send to Group(s) page

EU_SS_49

From the Send to Group(s) page after entering “au” to do some filtering

Email Users Beta (4991 downloads )

Email Users v4.7.10-beta-4 available

I have just posted beta-4 of Email Users v4.7.10.  This beta update fixes another issue with the line breaks (hopefully the last one) and also adds the capability to use or include the user’s email address when sorting and/or displaying the user selection lists.

EU_SS_46

Email Users Beta (4991 downloads )

Email Users v4.7.10-beta-3 available

I had started looking at bounce issues a while back but never completed the work.  It turns out bounce emails are problematic and the PHPMailer code included with WordPress has deprecated support for it.  I’ve made some minor changes that may help those trying to use the bounce email address capability.

I stress the “may” aspect of it because my own testing I have been unable to get it to work.  I have not seen anything not working from the changes I’ve made but I have not received any bounce emails either.  They simply seem to go in the bit bucket as far as I can tell.

Due to this unreliability I am recommending against using the bounce email address feature and have added a warning on the settings page advising as much which appears when a bounce address is set.

EU_SS_45

From looking at email headers this morning, I believe they are constructed properly.  I have no idea when bounced messages are actually routed versus discarded and different email servers seem to do it differently.

Email Users Beta (4991 downloads )

Email Users v4.7.10-beta-2 available

This version of Email Users adds a new option to enable apply WordPress’ wpautop function to post content prior to sending it as part of a Post/Page notification email.  This will allow retaining the line breaks in post content as they are shown with the visible editor.  This new option is NOT enabled by default – it must be set on the Email Users settings page.  I chose to do this because it would be a change of behavior for users who have been using the plugin and may yield unexpected results.

EU_SS_40

The difference between what a post notification with and without this setting checked can be seen in the following images:

Test Notification without “Process Content with wpautop” option:

EU_SS_43

Test Notification with “Process Content with wpautop” option:

EU_SS_42

Email received from “Send to User(s)”:

This option also ensures that email composed with the Visual Editor is correctly processed.  The images below show the compose screen within WordPress and the view of the received email within Gmail.

EU_SS_44

EU_SS_41

Download the beta and report any issues encountered.

Email Users Beta (4991 downloads )

Email User 4.7.6 released

About a week ago I got a notice from WordPress.org letting me know Email Users had been de-listed from the plugin repository due to potential security exploit. While the odds were low, it was still a vulnerability which required fixing. This came at a time I was heading to Taiwan for work so my ability to fix it quickly was limited.

This morning I had some cycles to work on it while traveling home. I made the necessary fixes, committed them to Subversion, and informed WordPress.org. I just received a notice from WordPress that Email Users has been listed again. It may take a day or two to propagate through their cache.

Look for the version update notice on your Dashboard and I highly recommend installing this update. There is one other fix for users who use the Ithinx Groups plugin which had a bug in it.

Understanding Email Users Options

Periodically I get support questions (on the WordPress Support forum) or comments here on my web site asking why Email Users doesn’t send email to some or all users as the plugin user expects it to.

Sometimes a user is dealing with an odd server restriction (e.g. email limits per hour, too many email addresses in the BCC field and others) but more frequently the target recipients don’t have their Email Users permissions set correctly.  This most frequently happens on a site where Email Users is added to a site that  already has a large set of users.

Email Users employs two options settings at the user level.  No matter what the settings are, any user within WordPress can always sent an email IF they are the only recipient.  This is by design.

The two settings are:

  • Allow Mass Emails:  Mass emails means that the user will accept email (Dashboard > Emails Users > Send to Users or Dasboard > Email Users > Send to Groups) where the resulting recipient list has more than one (1) recipient.  For a user in the WordPress database to receive email this permission must be enabled.
  • Allow Notifications:  Email Users has the ability to generate a notification email from a Post or Page (custom post types as well).  When using post or page notifications, only those users who have Notifications enabled will receive it.

Email Users has a default setting for these values which the WordPress admin can control.  It is on the plugin settings page (Dashboard > Settings > Email Users).

Email-Users-User-Options-1

These settings apply to all new users and when the plugin is activated the first time, are applied to all existing users.  The third option allows users to change their own settings by visiting their profile page.  When this option is enabled and a user visits their profile page, the following options are available for the user to change.

Email-Users-User-Options-2

 

The easiest way for the site administrator to review and change users’ settings, particularly on a site which has a lot of users, is to visit the User Settings Page (Dashboard > Email Users > User Settings).  This page will present all of the users (the number of users per page is set on the plugin settings page – see the image above for User Settings Table Rows) and their current settings.  The ability to perform bulk actions on a group of users is offered on this page.

Email-Users-User-Options-3

 

So if your users aren’t receiving emails, check their settings before heading down the debug path, often the solution is as simply as turning on the Mass Email option for the various users.

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';
}

Email Users v4.7.3-beta-1 available

This morning I posted beta-1 of Email Users v4.7.3.  This build addresses an out of memory error during plugin activation which was recently reported on the WordPress Support Forum.  This error would likely only happen on sites which very large numbers of users, 1500 or more, and is very dependent on the amount of memory the server has access to.

Email Users Beta (4991 downloads )

Email Users 4.7.2 released

Late last week there was a request on the WordPress Support Forum to add a filter to allow control over the HTML which wraps email content (post/page notifications or email to users/groups).

email_users_html_wrapper

This seemed like a reasonable request so I decided to look into it.  Adding a filter was fairly easy.  If the mailusers_html_wrapper filter exists, the default, and very basic, HTML wrapper is ignored and the filter is expected to properly construct the necessary HTML to wrap around email content.

This is the result of a email using the example filter now supplied as part of the plugin as viewed on my iPhone.

You can find the update in the WordPress plugin repository or an an update on your Dashboard.


/**
* To customize the look of HTML email or to integrate with other
* plugins which enhance wp_mail() (e.g. WP Better Emails), use this
* hook to wrap the email content with whatever HTML is desired - or
* in some cases, none at all if another plugin will be adding the
* necessary HTML.
*
* This example wraps an "Urgent" message and table around the email
* content so the background can be styled. A table is the best way
* to do this because not all mail clients will recognize styling
* elements such as BODY and DIV like a traditional web page.
*
* Drop this code snippet and modify to suit your needs into your
* theme's functions.php file.
*
* @see https://wordpress.org/plugins/wp-better-emails/
* @see https://litmus.com/blog/background-colors-html-email
*
*/
function mailusers_sample_html_wrapper($subject, $message, $footer)
{
// Wrap the HTML in proper header and body tags
// add some CSS styling to make the email look good.

$mailtext = sprintf('
<html>
<head>
<title>%s</title>
<style>
table { border: 1px solid black; width: 800px; background-color: #c5f6c0; }
td { background-color: #c5f6c0 }
</style>
</head>
<body>
<table class="content">
<tr>
<td class="content">
<div class="content">
<h1>This is an Urgent Message from Email Users!</h1>
%s
</div>
<div class="footer">
%s
</div>
</td>
</tr>
</table>
</body>
</html>', $subject, $message, $footer) ;

return $mailtext ;
}

add_filter('mailusers_html_wrapper', 'mailusers_sample_html_wrapper', 10, 3) ;

Email Users v4.7.1-beta-2 available

This evening I released beta-2 of Email Users v4.7.1.  This build addresses a couple of issues and introduces a new filter which allows manipulation of portions of the generated email headers.

The Dashboard Widget can now be disabled.  It is on by default but can be turned off with a setting (Dashboard > Settings > Email Users).

There have been several requests to support wpMandrill.  It wasn’t until recently that I learned that in addition to overloading wp_mail(), Mandrill requires the recipient addresses to be in the TO header where as Email Users uses the BCC header to send email.

I didn’t want to make it simple to use the TO header instead of the BCC header as I view it as risky.  Exposing the recipients of a mass mailing is a no-no.  However, Mandrill is widely used and with several requests, I needed a safe yet viable solution.

The new mailusers_manipulate_headers allows the user to modify the headers so they’ll work with Mandrill while not making it too easy to do so.  Here is an example of how the headers could/would be modified to have the recipients in the TO header instead of the BCC header.

/**
 * wpMandrill needs the recipients in the TO header instead
 * of the BCC header which Email Users uses by default. This
 * filter will move all of the recipients from the BCC header
 * into the TO header and clean up any formatting and then nuke
 * the BCC header.
 *
 */
function mailusers_mandrill_headers($to, $headers, $bcc)
{
    // Copy the BCC headers to the TO header without the "Bcc:" prefix
    $to = preg_replace('/^Bcc:\s+/', '', $bcc) ;

    // Empty out the BCC header
    $bcc = array() ;

    return array($to, $headers, $bcc) ;
}

add_filter('mailusers_manipulate_headers', 'mailusers_mandrill_headers', 10, 3) ;

This code would be placed in the functions.php file.  More details can found in the ReadMe.txt file.  The example above is now included with the plugin, you can find it in the examples directory.

Email Users Beta (4991 downloads )