Newsletter Plugin: Cron failing

Hi Greg,

The reason you're getting this message is that the time out limit for the PHP on your server is 30 seconds, but you're e-mailing script is taking longer than that to run. There are three ways you can fix this issue:

1) Reduce the number of messages that the script sends to 50, as this is roughly how many it sent before timing out.  You can do this in cmsAdmin/plugins/newsletterbuilder/background-mailer.php file on line 6:

  $GLOBALS['BACKGROUND_SEND_MAX']     = 50;  // max messages to send in each batch, eg: If a cronjob runs the script every 10 min and this is set to 80, you'll send approx 480 emails an hour

2) Increase/add the max_execution_time setting in your php.ini file to 120 seconds. (You could add this to the php.ini file in your cmsAdmin directory so it doesn't affect the entire site.

max_execution_time = 120; 

NOTE: Some hosting services disable this feature for security/efficiency reasons.

3) Increase the max execution time by adding a line to the background-mailer. This is not recommended as it requires changing CMSB plugin files, and we can't provide any support for issues that arise from it. If you go to around line 106 of the background mailer, you should see some code that looks like this:

 function _sendQueuedEmails() {
  $newsletterSettings  = mysql_get('_nlb_settings', 1);
  $count               = 0;
  $sendErrors          = '';
  $messagesByNum  

If you add this line to the function:

 function _sendQueuedEmails() {
  $newsletterSettings  = mysql_get('_nlb_settings', 1);
  $count               = 0;
  $sendErrors          = '';
  $messagesByNum       = array();

  //Increase the maximum execution time of the script to 120 seconds.
  set_time_limit(120);

The maximum execution time of the script will be increased to 120 seconds. NOTE: Some hosting services disable this feature for security/efficiency reasons.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By gversion - October 3, 2013

Hi Greg,

Thanks so much for the comprehensive response.

if I choose option 1, will I need to make this change every time I upgrade the Newsletter plugin?

Thank you,

Greg

Hi Greg,

Yes, you'll need to reset the settings in the background mailer every time you upgrade. So that is something to keep in mind.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com