Campaign Emails are queued, but it stops sending after about 78 or 79 recipients #1301

Open
opened 2026-02-20 15:08:03 -05:00 by deekerman · 15 comments
Owner

Originally created by @gitnito on GitHub (Oct 3, 2016).

Issue

Our campaign emails are all queued, but only about 79 or so are actually sent. PHPMailer fails after that number with an SMTP connect error. The "Number of emails sent per batch" setting under "Campaign Email Settings" is set to 500, and changing it does not affect anything. There are no limits on the SMTP account used (Google Apps for Work), and other applications are able to send thousands of email from the same account with no problem. If you go to the email queue, and click on "Send Campaign Queued Emails", it returns back immediately with no email sent, and nothing logged to the "suitecrm.log" file. Deleting the emails from the queue, and re-sending the campaign will send another batch of 79 or so (this basically proves the issue is NOT with the email account), however this is not a viable workaround, since it corrupt the campaign statistics by marking all of those emails as "Bounce Messages, Other". If the emails are left in the queue, they are continued to be sent at 10:00pm (where is this setting?) every day in batches of 79 or so.

Expected Behavior

When you click on send emails on a campaign, it should send all the emails up to "Number of emails sent per batch" setting under "Campaign Email Settings".

Actual Behavior

All emails are queued to be sent, but only about 79 emails are sent before PHPMailer starts filling the "suitecrm.log" file with the following errors one per failed email:
`Fri Sep 30 07:35:55 2016 [16301][d7def37c-25bd-194a-379a-57903117762f][FATAL] SugarPHPMailer encountered an error: The outbound mail server selected for the mail account you are using is invalid. Check the settings or select a different mail server for the mail account.
Fri Sep 30 07:35:55 2016 [16301][d7def37c-25bd-194a-379a-57903117762f][FATAL] SugarPHPMailer encountered an error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Fri Sep 30 07:35:55 2016 [16301][d7def37c-25bd-194a-379a-57903117762f][FATAL] Email delivery FAILURE:Array
(
[date_entered] => 2016-09-30 11:14:30
[date_modified] =>
[user_id] => d7def37c-25bd-194a-379a-57903117762d
[id] => 1563
[campaign_id] => ad50fd79-54c7-66d2-b3bf-57ede1a6a93e
[marketing_id] => 85f8fbdc-2cbf-d8e8-3634-57ee40c0d640
[list_id] => 206c8d0b-a311-0750-8f5f-57ed2a9692cc
[send_date_time] => 2016-09-30 11:15:00
[modified_user_id] =>
[in_queue] => 0
[in_queue_date] =>
[send_attempts] => 0
[deleted] => 0
[related_id] => e48baf5c-ece9-39ce-cdf6-57ed295f2820
[related_type] => Prospects
)

Fri Sep 30 07:35:55 2016 [16301][d7def37c-25bd-194a-379a-57903117762f][FATAL] Email delivery error:Array
(
[date_entered] => 2016-09-30 11:14:30
[date_modified] =>
[user_id] => d7def37c-25bd-194a-379a-57903117762d
[id] => 1563
[campaign_id] => ad50fd79-54c7-66d2-b3bf-57ede1a6a93e
[marketing_id] => 85f8fbdc-2cbf-d8e8-3634-57ee40c0d640
[list_id] => 206c8d0b-a311-0750-8f5f-57ed2a9692cc
[send_date_time] => 2016-09-30 11:15:00
[modified_user_id] =>
[in_queue] => 0
[in_queue_date] =>
[send_attempts] => 0
[deleted] => 0
[related_id] => e48baf5c-ece9-39ce-cdf6-57ed295f2820
[related_type] => Prospects
)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting`

Possible Fix

Some PHPMailer setting or bug.

Steps to Reproduce

  1. Create email campaign.
  2. Send the campaign emails.
  3. Monitor "suitecrm.log" file and SMTP account, and count the messages sent.
  4. Go to the email queue and check the remaining queued messages.

Context

We rely heavily on email campaigns for our customers to find our product; which they need, but do not know it exist. Thus, email campaign are our primary source of marketing, and this issue directly and severely limits our ability to generate new leads, and hence our daily sales.

Your Environment

  • SuiteCRM Version used: Version 7.7.4, Sugar Version 6.5.24 (Build 509)
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Firefox 50.0b3
  • Environment name and version (e.g. MySQL, PHP 7): mysql Ver 14.14 Distrib 5.5.52, for debian-linux-gnu (x86_64) using readline 6.3
  • Operating System and version (e.g Ubuntu 16.04): Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u3 (2016-01-17) x86_64 GNU/Linux
Originally created by @gitnito on GitHub (Oct 3, 2016). <!--- Provide a general summary of the issue in the **Title** above --> <!--- Before you open an issue, please check if a similar issue already exists or has been closed before. ---> #### Issue <!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug --> Our campaign emails are all queued, but only about 79 or so are actually sent. PHPMailer fails after that number with an SMTP connect error. The "Number of emails sent per batch" setting under "Campaign Email Settings" is set to 500, and changing it does not affect anything. There are no limits on the SMTP account used (Google Apps for Work), and other applications are able to send thousands of email from the same account with no problem. If you go to the email queue, and click on "Send Campaign Queued Emails", it returns back immediately with no email sent, and nothing logged to the "suitecrm.log" file. Deleting the emails from the queue, and re-sending the campaign will send another batch of 79 or so (this basically proves the issue is NOT with the email account), however this is not a viable workaround, since it corrupt the campaign statistics by marking all of those emails as "Bounce Messages, Other". If the emails are left in the queue, they are continued to be sent at 10:00pm (where is this setting?) every day in batches of 79 or so. #### Expected Behavior <!--- Tell us what should happen --> When you click on send emails on a campaign, it should send all the emails up to "Number of emails sent per batch" setting under "Campaign Email Settings". #### Actual Behavior <!--- Tell us what happens instead --> All emails are queued to be sent, but only about 79 emails are sent before PHPMailer starts filling the "suitecrm.log" file with the following errors one per failed email: `Fri Sep 30 07:35:55 2016 [16301][d7def37c-25bd-194a-379a-57903117762f][FATAL] SugarPHPMailer encountered an error: The outbound mail server selected for the mail account you are using is invalid. Check the settings or select a different mail server for the mail account. Fri Sep 30 07:35:55 2016 [16301][d7def37c-25bd-194a-379a-57903117762f][FATAL] SugarPHPMailer encountered an error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Fri Sep 30 07:35:55 2016 [16301][d7def37c-25bd-194a-379a-57903117762f][FATAL] Email delivery FAILURE:Array ( [date_entered] => 2016-09-30 11:14:30 [date_modified] => [user_id] => d7def37c-25bd-194a-379a-57903117762d [id] => 1563 [campaign_id] => ad50fd79-54c7-66d2-b3bf-57ede1a6a93e [marketing_id] => 85f8fbdc-2cbf-d8e8-3634-57ee40c0d640 [list_id] => 206c8d0b-a311-0750-8f5f-57ed2a9692cc [send_date_time] => 2016-09-30 11:15:00 [modified_user_id] => [in_queue] => 0 [in_queue_date] => [send_attempts] => 0 [deleted] => 0 [related_id] => e48baf5c-ece9-39ce-cdf6-57ed295f2820 [related_type] => Prospects ) Fri Sep 30 07:35:55 2016 [16301][d7def37c-25bd-194a-379a-57903117762f][FATAL] Email delivery error:Array ( [date_entered] => 2016-09-30 11:14:30 [date_modified] => [user_id] => d7def37c-25bd-194a-379a-57903117762d [id] => 1563 [campaign_id] => ad50fd79-54c7-66d2-b3bf-57ede1a6a93e [marketing_id] => 85f8fbdc-2cbf-d8e8-3634-57ee40c0d640 [list_id] => 206c8d0b-a311-0750-8f5f-57ed2a9692cc [send_date_time] => 2016-09-30 11:15:00 [modified_user_id] => [in_queue] => 0 [in_queue_date] => [send_attempts] => 0 [deleted] => 0 [related_id] => e48baf5c-ece9-39ce-cdf6-57ed295f2820 [related_type] => Prospects ) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting` #### Possible Fix <!--- Not obligatory, but suggest a fix or reason for the bug --> Some PHPMailer setting or bug. #### Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug include code to reproduce, if relevant --> 1. Create email campaign. 2. Send the campaign emails. 3. Monitor "suitecrm.log" file and SMTP account, and count the messages sent. 4. Go to the email queue and check the remaining queued messages. #### Context <!--- How has this bug affected you? What were you trying to accomplish? --> <!--- If you feel this should be a low/medium/high priority then please state so --> We rely heavily on email campaigns for our customers to find our product; which they need, but do not know it exist. Thus, email campaign are our primary source of marketing, and this issue directly and severely limits our ability to generate new leads, and hence our daily sales. #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> - SuiteCRM Version used: Version 7.7.4, Sugar Version 6.5.24 (Build 509) - Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Firefox 50.0b3 - Environment name and version (e.g. MySQL, PHP 7): mysql Ver 14.14 Distrib 5.5.52, for debian-linux-gnu (x86_64) using readline 6.3 - Operating System and version (e.g Ubuntu 16.04): Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u3 (2016-01-17) x86_64 GNU/Linux
Author
Owner

@shogunpol commented on GitHub (Oct 17, 2016):

@gitnito , just ask about additional info: can you check if outbound server has a limit of sended emails?

@shogunpol commented on GitHub (Oct 17, 2016): @gitnito , just ask about additional info: can you check if outbound server has a limit of sended emails?
Author
Owner

@ijdavie commented on GitHub (Oct 17, 2016):

@gitnito there is a limit to the gmail servers, it is higher than what you are seeing here. is there a possibility that the gmail server is refusing the amount of emails in such a small period of time ?

@ijdavie commented on GitHub (Oct 17, 2016): @gitnito there is a limit to the gmail servers, it is higher than what you are seeing here. is there a possibility that the gmail server is refusing the amount of emails in such a small period of time ?
Author
Owner

@gitnito commented on GitHub (Oct 28, 2016):

@shogunpol I had the problem happen with the limit set to the default of 500, and it still happened when I changed it to 1000. Recently I tried it setting it to 50, and surprisingly this made it better. Emails where sent without failure, but not continuously, since it did it in batches of 50 (which well below the 75-80 at which it would fail before). If I had to guess, it seems to me that the underlying PHPMailer must have a limit or some failure check around the 75-80.

@gitnito commented on GitHub (Oct 28, 2016): @shogunpol I had the problem happen with the limit set to the default of 500, and it still happened when I changed it to 1000. Recently I tried it setting it to 50, and surprisingly this made it better. Emails where sent without failure, but not continuously, since it did it in batches of 50 (which well below the 75-80 at which it would fail before). If I had to guess, it seems to me that the underlying PHPMailer must have a limit or some failure check around the 75-80.
Author
Owner

@gitnito commented on GitHub (Oct 28, 2016):

@ijdavie I have had quite long conversation with Google support engineers that can directly look into my account to see if any limit was being triggered, and they tell that did not happened. My gmail account is a Google Apps for Work account, and the only limit is has is a 2500 unique recipients per rolling 24 hr. Further, I have used mail merge under Mozilla Thunderbird with the same gmail account to continuously send thousands of emails at a fast rate with no problems other than the 2500/24hr limit. Thus to answer your question; no, I don't think there is any issue with the gmail account (in fact I know for a fact, since Google engineers looked into my account status while this was happening, and said there was no issue on their end).

@gitnito commented on GitHub (Oct 28, 2016): @ijdavie I have had quite long conversation with Google support engineers that can directly look into my account to see if any limit was being triggered, and they tell that did not happened. My gmail account is a Google Apps for Work account, and the only limit is has is a 2500 unique recipients per rolling 24 hr. Further, I have used mail merge under Mozilla Thunderbird with the same gmail account to continuously send thousands of emails at a fast rate with no problems other than the 2500/24hr limit. Thus to answer your question; no, I don't think there is any issue with the gmail account (in fact I know for a fact, since Google engineers looked into my account status while this was happening, and said there was no issue on their end).
Author
Owner

@chris001 commented on GitHub (Oct 28, 2016):

@gitnito As a workaround,, you should set the "Number of emails sent per batch" to 50 per batch, and set it to send as often as something like one batch per 5 minutes.

@chris001 commented on GitHub (Oct 28, 2016): @gitnito As a workaround,, you should set the "Number of emails sent per batch" to 50 per batch, and set it to send as often as something like one batch per 5 minutes.
Author
Owner

@gitnito commented on GitHub (Oct 28, 2016):

@chris001 That is what I have been doing. But I don't remember if I changed the frequency of batches. Where would I change that?

@gitnito commented on GitHub (Oct 28, 2016): @chris001 That is what I have been doing. But I don't remember if I changed the frequency of batches. Where would I change that?
Author
Owner

@chris001 commented on GitHub (Oct 29, 2016):

@gitnito
Admin / Schedules / Run nightly mass email campaigns.
Hit Edit.
Change Interval Min. from 0,10,20,30,40,50 to */5 for every 5 minutes. Or, do */2 for every 2 minutes. Or, do * for every minute.
Change Interval Hrs to 2-18 this is 24 hour time, corresponds to 2am-6pm.
Hit Save.
Try it out, it should work.

@chris001 commented on GitHub (Oct 29, 2016): @gitnito Admin / Schedules / Run nightly mass email campaigns. Hit Edit. Change `Interval Min.` from `0,10,20,30,40,50` to `*/5` for every 5 minutes. Or, do `*/2` for every 2 minutes. Or, do `*` for every minute. Change `Interval Hrs` to `2-18` this is 24 hour time, corresponds to 2am-6pm. Hit Save. Try it out, it should work.
Author
Owner

@shogunpol commented on GitHub (Nov 2, 2016):

@gitnito , it is very possible the problem what causing the malfunctioning of the email campaigns it can be using PHP7, because is very difficult to replicate an issue for me, can you check is this issue appear after using lower version of PHP?
Thanks for your contribution.

@shogunpol commented on GitHub (Nov 2, 2016): @gitnito , it is very possible the problem what causing the malfunctioning of the email campaigns it can be using PHP7, because is very difficult to replicate an issue for me, can you check is this issue appear after using lower version of PHP? Thanks for your contribution.
Author
Owner

@gitnito commented on GitHub (Nov 2, 2016):

I am using PHP Version 5.6.27-0+deb8u1, and I can not change it.

@gitnito commented on GitHub (Nov 2, 2016): I am using PHP Version 5.6.27-0+deb8u1, and I can not change it.
Author
Owner

@ijdavie commented on GitHub (Nov 2, 2016):

@gitnito just a thought with this, could this be down to the hosting provider for the CRM. I wonder if it may have something to do with amount of connections the server will allow ?

@ijdavie commented on GitHub (Nov 2, 2016): @gitnito just a thought with this, could this be down to the hosting provider for the CRM. I wonder if it may have something to do with amount of connections the server will allow ?
Author
Owner

@chris001 commented on GitHub (Nov 3, 2016):

@ijdavie Good question. So then, how many simultaneous SMTP connections does phpmailer library, the sugarmailer class, and the Campaigns module, require from the smtp server, in order for the Campaigns scheduler to run without error?

@chris001 commented on GitHub (Nov 3, 2016): @ijdavie Good question. So then, how many simultaneous SMTP connections does phpmailer library, the sugarmailer class, and the Campaigns module, require from the smtp server, in order for the Campaigns scheduler to run without error?
Author
Owner

@ijdavie commented on GitHub (Nov 4, 2016):

@chris001, I would have thought that the phpmailer library wouldnt have a issue with this and more so with the server it sits on so I mean if the server picks up that something is trying to send XXX amount of emails after so many requests it stops this due to it thinking it is not normal. @chris001 have you been able to replicate this issue ?

@ijdavie commented on GitHub (Nov 4, 2016): @chris001, I would have thought that the phpmailer library wouldnt have a issue with this and more so with the server it sits on so I mean if the server picks up that something is trying to send XXX amount of emails after so many requests it stops this due to it thinking it is not normal. @chris001 have you been able to replicate this issue ?
Author
Owner

@chris001 commented on GitHub (Nov 5, 2016):

@ijdavie @gitnito @shogunpol With an hour of digging into the code, I created Pull Request #2569 which should make the Campaign Emails send a lot better when your SMTP outgoing email server is complaining because you're putting it under high load from sending too many emails in per batch.
If you would, try it out and report back to let us know if your issue is solved.

@chris001 commented on GitHub (Nov 5, 2016): @ijdavie @gitnito @shogunpol With an hour of digging into the code, I created Pull Request #2569 which should make the Campaign Emails send a lot better when your SMTP outgoing email server is complaining because you're putting it under high load from sending too many emails in per batch. If you would, try it out and report back to let us know if your issue is solved.
Author
Owner

@amariussi commented on GitHub (May 25, 2018):

Instead of hard coding it in the code it would be better to use a config field so that anyone can decide whether he wants or not to use this approach, which, according to many, may lead to be signaled as spammers for various reasons.
It's only a matter of making a very small change in the if statement.

@amariussi commented on GitHub (May 25, 2018): Instead of hard coding it in the code it would be better to use a config field so that anyone can decide whether he wants or not to use this approach, which, according to many, may lead to be signaled as spammers for various reasons. It's only a matter of making a very small change in the if statement.
Author
Owner

@Mausino commented on GitHub (May 25, 2018):

@amariussi i agree too. it should lead to problems like here #3423 SMTP Spamming

@Mausino commented on GitHub (May 25, 2018): @amariussi i agree too. it should lead to problems like here #3423 SMTP Spamming
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#1301
No description provided.