If you set it to 60 emails per hour, it sends 1 email every minute, and no, it doesn’t send it randomly, I think 60 emails per hour isn’t too bad for throttling. If you want to space it out, like a delay between email, then that is a different story, and it shouldn’t be that difficult to do:
Note: I haven’t tested this, just writing this at the top of my head, so, you might want to run a test to see if it works, but, I am certain, it would work, there are multiple ways to do this, so, I’ll give you the best method I can think off:
Replace The Specific Cron Job With Systemd
Systemd is well more robust than cron, I won’t get into why, as that is not the question, to set a systemd, we would use the following features:
Services: This is the place you run the mautic email send command
Timers: You can set when to run the service, you can run the command every 10 seconds, or every 30 seconds, and even add random delays, cool right
Let’s get into the creation, create a service as follows:
sudo nano /etc/systemd/system/mautic-throttle.service
Inside the file add the following:
[Unit]
Description=Throttle mautic emails
Wants=mautic-throttle.timer
[Service]
ExecStart=/usr/bin/php /var/www/mautic/bin/console mautic:emails:send > /dev/null
WantedBy=multi-user.target
Now, let’s set the timer, create and open the following as follows:
sudo nano /etc/systemd/system/mautic-throttle.timer
To run the email every 50 seconds + some random duration below 50 seconds, you add the following:
[Unit]
Description=Run mautic-throttle.service every 50 seconds
Requires=mautic-throttle.service
[Timer]
Unit=mautic-throttle.service
OnUnitInactiveSec=50
RandomizedDelaySec=50
AccuracySec=1s
Persistent=True
[Install]
WantedBy=timers.target
If for example, you want to send email every 5 minutes and you want to randomized the sending below 2 minutes, you change the OnUnitInactivesec and RandomizedDelaySec to:
OnUnitInactiveSec=5m
RandomizedDelaySec=2m
To finalize it, you install the services using:
sudo systemctl daemon-reload
sudo systemctl enable mautic-throttle.timer
sudo systemctl start mautic-throttle
If something went wrong when setting up a service, you can find it out by running
systemctl status mautic-throttle
Optional
systemctl list-timers # view the status of the timers
journalctl -u mautic-throttle # view the logs of the mautic-throttle
This is a robust method, and you can control a lot more rather than relying on cron job, if you know bash scripting, then you can automate all this process easily.
I wrote all this on my smartphone, so, there might be some mistakes, let me know how it goes.