Process regular campaigns and autoresponders separately


Staff member
By default, mailwizz 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, either 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 explatory, 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 thried 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.


Great stuff man and with the patch applied the system actually hauls ass like this.

One question, implementing all of this if I give a directive of 100 emails a minute, is that still followed>



Staff member
One question, implementing all of this if I give a directive of 100 emails a minute, is that still followed>
It should yes. The command line arguments only override the number of campaigns and from where to start processing, everything else still gets inherited from settings.
I have tried to separate the cron for autoresponder and regular campaign as explained, but campaigns stopped sending.

The only difference with the cron is that in my installation I have /usr/bin/php-cli -q instead of /usr/bin/php -q
I don't know if this has something to do with the problem.

Also, when you have a lot of clients a lot of campaigns, especially auto-responders, can add up quickly and reach the 2K-3K campaigns.
What would be the best way to handle this?
A cron job every 50 or 100 offset parameter?
OK... so any idea why the separation between auto-responders and regular campaigns didn't work for me?
Is it not working with the latest version of MW?


Staff member
It working but it's a complicated process that requires more attention that's why is better to be avoided if there are alternatives.