SMTP sending only 20/minutes on two clean Mautic installations

Your software
My Mautic version is: 3.3.4
My PHP version is: 7.4.23
My Database type and version is:MySQL 5.7

Your problem
My problem is: Two mautic installation set with SMTP and to send 80/minutes (first tried 300/minute too) is only sending 20 emails/minute no matter what I do. Spool directory fills up with thousands of files to send, but only 20/minute are being sent (and deleted from the spool directory).
SMTP tested separately and can send way more per minute (tested with 80/minute with no problem), reported limit to f the system is 5,000/hour.

Setting in Mautic currently is 80/minute. This was tested on two separate mautic installations and multiple campaign, Mautic is set to queue, cron email:send is called every minute. ( * * * * * ).

These errors are showing in the log: no errors shown.

Steps I have tried to fix the problem: redo cron jobs, change throttling in mautic config to different values , tested SMTP to verify no problem with it to send way more per minute, monitored mautic spool directly and no matter what I do, sends emails and delete them from the spool directory in a rate of only 20/minute.

Help!

Maybe your setup is not strong enough to send 80/ min?

Hi, that’s not the reason, there is no noticeable system load at all. I can also see that the 20 emails sent every minute are processed within less than a second every minute, then the system just waits for a minute doing nothing.

Did you spool all your emails prior to sent? Is the broadcast cron running at the same time as the email send cron? If so, they maybe you are spooling and sending at the same time. Not optimal.

You are saying, that email sending is set to every minute, right? Do you use any limitation for amount sent? If you have 1000 emails and set email send every minute, then after minute 2 you have 2 concurrent scripts running paralell where script 2 will fail, since it’s trying to send the same emails. After minute 3 you have 2 scripts failing, etc.

Check this Mautic Meetup:

I see all the email files in the spool directory shortly after the scheduled campaign kicks in.
The campaigns I tired had between 1,000-8,000 emails per campaign, so I see that amount of files in the spool directory when the campaign no starts.
I manually monitored the spool directory, and see that every minute there’s a reduction of 20 files in the spool directory file count, and it’s instant (I never saw a graduate reduction, like 5 or 10 emails and then more) but it’s instant reduction of 20 files every minute (2150, after a minute drops to 2130 at once, then 2110 and so on until zero after a few hours). I also see get feedback from read count and other that this is the rate the emails are sent out.
Broadcast job is every 5 minutes (does it affect send jobs?). Send job is every minute.
I have Message limit for queue processing in mautic config set to 80. Do not send me more than is set to 120,000/day.
I tested the smtp speed using a test program and there is no problem sending 80+/minute.
Thanks.

Back to my original question: when you run the email:send cron, do you limit how many you are sending?
Or your script just runs every minute with a new thread after 10 minutes having 10 concurrent threads?

I have “Message limit for queue processing” in mautic config set to 80. “Do not send me more than” is set to 120,000/day.
The cron job email:send is called every minute.

Is there any other place or way to limit it?

Thanks.

UPDATE - I bypassed for now by doing this:

          • php7.4 /path/mautic/bin/console mautic:email:send
          • sleep 10; php7.4 /path/mautic/bin/console mautic:email:send
          • sleep 20; php7.4 /path/mautic/bin/console mautic:email:send
          • sleep 30; php7.4 /path/mautic/bin/console mautic:email:send
            Not my favorite solution, but works (sending an email right now with it). every minute I got 20 emails sent 4 times 0, 10, 20, 30 seconds into the minute. I see the file number in the spool directory decreasing 4 times (the decrease takes no time at all, I never saw a partial of the 20 goes down). So with that, I get 80/minute (5k/hour) sent with no problem and no noticeable server load. Still wanna solve it in a more elegant way (i.e. figure out why it’s sending only 20 with each batch). Thanks.

@lior

You are on a good path. However this is generating a LOT of errors. Don’t do it. How about this?

          • php7.4 /path/mautic/bin/console mautic:email:send –time-limit=50 --lock_mode=flock
          • sleep 10; php7.4 /path/mautic/bin/console mautic:email:send –time-limit=40 --lock_mode=flock
            etc…

lock mode: file lock (flock) it will help your mautic not to try to send the same emails
time-limit will make sure your command only runs for a minute, so at every minute you have a new fresh thread

I’m not sure why it will produce errors - you assume it will take more than 10 seconds for each command to process the emails?

So maybe a combo like this (just in case any takes more than 9 seconds, without flock):

          • timeout 9s php7.4 /path/mautic/bin/console mautic:email:send
          • sleep 10; timeout 9s php7.4 /path/mautic/bin/console mautic:email:send
          • sleep 20; timeout 9s php7.4 /path/mautic/bin/console mautic:email:send
          • sleep 30; timeout 9s php7.4 /path/mautic/bin/console mautic:email:send

Still want to understand why only 20 are processed…

Well check your logs. No errors like ‘try to send but email doesn’t exists’?