Process regular campaigns and autoresponders separately

Process regular campaigns and autoresponders separately

By default, AppMail will process both, regular campaigns and autoresponders in the same time. This is good for small installations that don’t have multiple campaigns that are sending at once.

If the “Campaigns at once” setting from Backend -> Settings -> Cron is set to 5 for example and you set 5 autoresponders to send this means that the 6th campaign, regular, either autoresponder won’t trigger anymore because those 5 slots are occupied by those 5 autoresponders.
You can simply increase the number of campaigns at once to alleviate this, but this will only work till certain point.
A better way is to simply split the send-campaigns cron command into two separate commands. If your cron job for send campaigns is looking like:

* * * * * /usr/bin/php -q /home/domain/public_html/apps/console/console.php send-campaigns >/dev/null 2>&1

Then you can simply edit it like:

* * * * * /usr/bin/php -q /home/domain/public_html/apps/console/console.php send-campaigns --campaigns_type=regular >/dev/null 2>&1

Then add a new cron job for autoresponders:

* * * * * /usr/bin/php -q /home/domain/public_html/apps/console/console.php send-campaigns --campaigns_type=autoresponder >/dev/null 2>&1

What the above does is pretty self-explanatory, each command will process separately a type of campaigns, that is one will process regular campaigns, and one will process autoresponders.
Those commands still depend on the number of “Campaigns at once” set in your Backend -> Settings -> Cron, so if you set 10 campaigns at once, it means the system will process 10 regular campaigns and 10 autoresponders at once.
This can cause issues because again if there are more then 10 autoresponders active at once, it can happen that not all of them can be processed and if you increase the number of Campaigns at once from backend the new limit will also apply to regular campaigns, which might be not what you want.
If that’s the case, the send-campaigns command also accepts a limit parameter so you can explicitly say:

* * * * * /usr/bin/php -q /home/domain/public_html/apps/console/console.php send-campaigns --campaigns_type=autoresponder --campaigns_limit=50 >/dev/null 2>&1

And that means that regardless of your backend settings for campaigns at once, the system will always process 50 autoresponders at once and the backend settings are not taken into consideration anymore.
You can do the same for regular campaigns:

* * * * * /usr/bin/php -q /home/domain/public_html/apps/console/console.php send-campaigns --campaigns_type=regular --campaigns_limit=20 >/dev/null 2>&1

And again the system will process 20 campaigns at once regardless of your backend settings.
To process even more, the send-campaigns command also accepts an offset parameter, so if needed be and there are too many campaigns to process at once, one can simply change the send-campaigns cron jobs like:

* * * * * /usr/bin/php -q /home/domain/public_html/apps/console/console.php send-campaigns --campaigns_type=regular --campaigns_limit=50 --campaigns_offset=0 >/dev/null 2>&1
* * * * * /usr/bin/php -q /home/domain/public_html/apps/console/console.php send-campaigns --campaigns_type=regular --campaigns_limit=50 --campaigns_offset=50 >/dev/null 2>&1
* * * * * /usr/bin/php -q /home/domain/public_html/apps/console/console.php send-campaigns --campaigns_type=regular --campaigns_limit=50 --campaigns_offset=100 >/dev/null 2>&1

What the above does, is to start 3 separate commands to process campaigns in the same time.
The first command will process first 50 campaigns; the second command will jump over first 50 and will process next 50 and the tried will jump over first 100 and process next 50.
Same can be done for autoresponders:

* * * * * /usr/bin/php -q /home/domain/public_html/apps/console/console.php send-campaigns --campaigns_type=autoresponder --campaigns_limit=10 --campaigns_offset=0 >/dev/null 2>&1
* * * * * /usr/bin/php -q /home/domain/public_html/apps/console/console.php send-campaigns --campaigns_type=autoresponder --campaigns_limit=10 --campaigns_offset=10 >/dev/null 2>&1
* * * * * /usr/bin/php -q /home/domain/public_html/apps/console/console.php send-campaigns --campaigns_type=autoresponder --campaigns_limit=10 --campaigns_offset=20 >/dev/null 2>&1

The above examples will use 3 separate commands, but you can literally use as many as you need and as many as your system can cope with, so use these with caution.

    • Related Articles

    • Delete campaigns command

      Deleting old campaigns, that you don't need anymore, will free up a lot of disk space. This in turn will result in a faster application because there will be less data AppMail has to go through in order to complete operations. The delete-campaigns ...
    • Recurring Campaigns

      One great feature of AppMail is recurring campaigns, which means you can set it in a way that every 10th of each month you could send an RSS FEED campaign with latest blog posts. But this is not all, you can even set it to send in various days of the ...
    • My Autoresponders don’t send

      Most likely the reason for this is the number of campaigns at once from Backend > Settings > Cron, so try to put there a higher number, like 50 and see if that fixes the problem.
    • Debug send-campaigns command

      Starting with version 1.3.5, the cron job command that sends campaigns (send-campaigns) has been modified so that it will help debugging sending speed. In order to make use of this functionality, you should have ssh access to your server so that you ...
    • Archive campaigns delivery logs

      Since AppMail stores a lot of data, there is one table in particular that will grow very much, that is, the table that store delivery info for each subscriber, its name is `campaign_delivery_log`. This can be problematic for small servers since ...