Support » Plugin: Email Users » 502 Timeout Errors with many users

  • info2grow


    Just curious if it’s possible to stop the plugin from looping through all users when loading the Send to Groups screen. We have 5000+ users and just want to send to a small group of them using the ITThinx Groups integration but it seems that in order to build the page the plugin is looping through all users when it might be able to get away with just querying users based on a group selection when send is hit.

    I would love to help if you can point me in the right direction. I would also be happy to pay you for this modification so we can continue using this helpful plugin!

    • This topic was modified 4 months ago by  info2grow.
Viewing 6 replies - 1 through 6 (of 6 total)
  • info2grow


    so far I’ve narrowed it to integration/itthinx-groups.php line 87

    // Make sure the list of IDs accounts for the Email Users settings for email
    $ids = mailusers_get_recipients_from_ids($ids, $exclude_id, $meta_filter) ;

    If I comment out that line the send to groups page loads…



    Digging deeper it’s actually with get_users is called in email_users.php on line 1436 that is actually stopping the initial page load of Send to Group(s). Obviously that needs to be there but does it need to happen on page load specifically for send to groups?

    To be clear when either of these lines are not commented out the send to groups page will not load at all and I get a 502. It looks like the code may be looping through all groups and assigning the associated ids of users in each those groups on page load. Perhaps we can just query users of the chosen groups after Send Email is pressed?

    Plugin Author Mike Walsh


    I apologize for the delayed response. I am out of the country this week on vacation and have nothing but an iPad with me so looking at this issue is a challenge.

    5000 users is a lot so it doesn’t surprise me you are seeing a problem. A number of years ago I had a similar problem with Send to Users with someone who had 8000+ users on the site. The solution was to break the query up into chunks. I cannot recall it I ever added the same solution to groups or not, based on your description I am guessing I did not.

    I won’t be back in the US until Sunday and I suspect catching up on work email will take me a day or two. I will try to look into this next week when I am home. If you find a solution and want to send me a patch, I’d be happy to consider incorporating it.



    Thanks Mike! I think I have it sorted…

    in mail-users/integration/itthinx-groups.php

    It looks like it was the code that checks for empty groups.

    In function mailusers_get_itthinx_groups

    1. comment out line 52 as we are already getting the ids on send
    2. Remove the if clause from line 54 that checks for empty groups
    3. We still need a check for empty groups inside function mailusers_get_recipients_from_itthinx_groups_group on line 80 so I added another clause. It works but there may be a better way.

      if ((is_array($group) || is_object($group)) && $group->__get('users')) {

    4. then we need to check if the ids array is empty before calling mailusers_get_recipients_from_ids on line 88
          //  Make sure the list of IDs accounts for the Email Users settings for email
          $ids = mailusers_get_recipients_from_ids($ids, $exclude_id, $meta_filter) ;

    Worked for a small group, now I am about to try a group of 750…



    Update no 502 loading the page so the code above addressed that however when sending to 750 users I got 502 partway through. 293 emails were sent successfully.

    We host with WPEngine and use Mailgun (and the Mailgun plugin) to handle the actual sending of the emails.

    in email-users.php I have number set to 100 on line 1353 if that helps

    //  Set up the arguments for get_users()
        $args = array_merge($args, array(
            'exclude' => array($exclude_id),
            //'fields' => array('ID', 'display_name', 'user_email'),
            'fields' => 'all',
            'offset' => '0',
            'number' => '100',
        )) ;
    • This reply was modified 4 months ago by  info2grow.
    • This reply was modified 4 months ago by  info2grow.

    @mpwalsh8 Update? I’m having the same issue on my site with 2000+ users. It takes a good 1 minute before it loads the page. I’m fearing if this continues It will stop working altogether.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.