Sending via REST API only sends a few emails

Your software
My Mautic version is: 5.1.0
My PHP version is: PHP 8.1.2-1ubuntu2.19
My Database type and version is: 10.6.18-MariaDB-0ubuntu0.22.04.1

Hello,

I’m creating a template email and sending it to a segment of 50k recipients using the REST API /emails/ID/send endpoint. The email is created correctly, and it is then sent to about 2.700 recipients. Then it just stops.

When I open the email that was created with the API and click “send” in the web interface, the remaining 47k emails are sent without problems. When I try to send to a smaller segment (10 recipients) with the API, all emails are sent on the first try.

I have no limits and enough allowance with my SMTP provider. There are no entries in the log file.

Thank you for reading, and kind regards!

Solved my own problem by reading the docs. I was not aware that Mautic had switched to using queues as documented here.

Here’s what I did:

I enabled queueing with doctrine as described in the docs and set up a worker using systemctl. This is my service file:

# /etc/systemd/system/mautic-worker.service

[Unit]
Description=Mautic Messenger Worker
After=network.target

[Service]
User=www-data
ExecStart=/usr/bin/php /opt/mautic/bin/console messenger:consume email
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal
Environment=SYMFONY_ENV=prod

[Install]
WantedBy=multi-user.target

I started and enabled the worker with

systemctl enable mautic-worker
systemctl start mautic-worker

Then I added the following line to the crontab. I measured that this call takes about 2 minutes, so I gave it 4 just to be sure:

*/4 * * * * sudo -u www-data php /opt/mautic/bin/console mautic:broadcasts:send --channel=email --limit=1000 --batch=1000

Now everything works as intended. Just make sure the emails are published and have publish_at date set, else they won’t get processed. Also set the unpunblish_at date if you don’t want contacts that are added to that segment after you’ve created the email to receive it.

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.