Send scheduled broadcasts not working

Your software
My Mautic version is: 5.2.1
My PHP version is: PHP/8.1.31
My Database type and version is: mysql:9.1.0

Your problem
I am trying to send a segment email following the Send Scheduled Broadcasts (Segment Emails) Cron Job documentation, but I am unable to do so.
My Cron Job executes, but it throws a Symfony\Component\Messenger\Exception\TransportException

My mautic cron file:

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
BASH_ENV=/tmp/cron.env

          • php /var/www/html/bin/console mautic:segments:update 2>&1 | tee /tmp/stdout
          • php /var/www/html/bin/console mautic:campaigns:update 2>&1 | tee /tmp/stdout
          • php /var/www/html/bin/console mautic:campaigns:trigger 2>&1 | tee /tmp/stdout
          • php /var/www/html/bin/console mautic:broadcasts:send --limit=200 2>&1 | tee /tmp/stdout

These errors are showing in the log:

[2025-01-07T22:10:03.252284+00:00] mautic.ERROR: Symfony\Component\Messenger\Exception\TransportException: Could not connect to the AMQP server. Please verify the provided DSN. (uncaught exception) at /var/www/html/vendor/symfony/amqp-messenger/Transport/AmqpSender.php line 77 while running console command `mautic:broadcasts:send` [stack trace] #0 /var/www/html/vendor/symfony/amqp-messenger/Transport/AmqpTransport.php(75): Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpSender->send(Object(Symfony\Component\Messenger\Envelope)) #1 /var/www/html/vendor/symfony/messenger/Middleware/SendMessageMiddleware.php(68): Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpTransport->send(Object(Symfony\Component\Messenger\Envelope)) #2 /var/www/html/vendor/symfony/messenger/Middleware/FailedMessageProcessingMiddleware.php(34): Symfony\Component\Messenger\Middleware\SendMessageMiddleware->handle(Object(Symfony\Component\Messenger\Envelope), Object(Symfony\Component\Messenger\Middleware\StackMiddleware)) #3 /var/www/html/vendor/symfony/messenger/Middleware/DispatchAfterCurrentBusMiddleware.php(68): Symfony\Component\Messenger\Middleware\FailedMessageProcessingMiddleware->handle(Object(Symfony\Component\Messenger\Envelope), Object(Symfony\Component\Messenger\Middleware\StackMiddleware)) #4 /var/www/html/vendor/symfony/messenger/Middleware/RejectRedeliveredMessageMiddleware.php(48): Symfony\Component\Messenger\Middleware\DispatchAfterCurrentBusMiddleware->handle(Object(Symfony\Component\Messenger\Envelope), Object(Symfony\Component\Messenger\Middleware\StackMiddleware)) #5 /var/www/html/vendor/symfony/messenger/Middleware/AddBusNameStampMiddleware.php(37): Symfony\Component\Messenger\Middleware\RejectRedeliveredMessageMiddleware->handle(Object(Symfony\Component\Messenger\Envelope), Object(Symfony\Component\Messenger\Middleware\StackMiddleware)) #6 /var/www/html/vendor/symfony/messenger/MessageBus.php(77): Symfony\Component\Messenger\Middleware\AddBusNameStampMiddleware->handle(Object(Symfony\Component\Messenger\Envelope), Object(Symfony\Component\Messenger\Middleware\StackMiddleware)) #7 /var/www/html/vendor/symfony/mailer/Mailer.php(63): Symfony\Component\Messenger\MessageBus->dispatch(Object(Symfony\Component\Mailer\Messenger\SendEmailMessage)) #8 /var/www/html/docroot/app/bundles/EmailBundle/Helper/MailHelper.php(390): Symfony\Component\Mailer\Mailer->send(Object(Mautic\EmailBundle\Mailer\Message\MauticMessage)) #9 /var/www/html/docroot/app/bundles/EmailBundle/Helper/MailHelper.php(469): Mautic\EmailBundle\Helper\MailHelper->send(false) #10 /var/www/html/docroot/app/bundles/EmailBundle/Model/SendEmailToContact.php(379): Mautic\EmailBundle\Helper\MailHelper->queue(false, 'RETURN_ERRORS') #11 /var/www/html/docroot/app/bundles/EmailBundle/Model/SendEmailToContact.php(190): Mautic\EmailBundle\Model\SendEmailToContact->sendStandardEmail() #12 /var/www/html/docroot/app/bundles/EmailBundle/Model/EmailModel.php(1450): Mautic\EmailBundle\Model\SendEmailToContact->send() #13 /var/www/html/docroot/app/bundles/EmailBundle/Model/EmailModel.php(1083): Mautic\EmailBundle\Model\EmailModel->sendEmail(Object(Mautic\EmailBundle\Entity\Email), Array, Array) #14 /var/www/html/docroot/app/bundles/EmailBundle/EventListener/BroadcastSubscriber.php(48): Mautic\EmailBundle\Model\EmailModel->sendEmailToLists(Object(Mautic\EmailBundle\Entity\Email), Object(Doctrine\ORM\PersistentCollection), 199, 50, Object(Symfony\Component\Console\Output\ConsoleOutput), NULL, NULL, NULL, NULL) #15 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(270): Mautic\EmailBundle\EventListener\BroadcastSubscriber->onBroadcast(Object(Mautic\ChannelBundle\Event\ChannelBroadcastEvent), 'mautic.channel_...', Object(Symfony\Component\EventDispatcher\EventDispatcher)) #16 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(230): Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}(Object(Mautic\ChannelBundle\Event\ChannelBroadcastEvent), 'mautic.channel_...', Object(Symfony\Component\EventDispatcher\EventDispatcher)) #17 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(59): Symfony\Component\EventDispatcher\EventDispatcher->callListeners(Array, 'mautic.channel_...', Object(Mautic\ChannelBundle\Event\ChannelBroadcastEvent)) #18 /var/www/html/docroot/app/bundles/ChannelBundle/Command/SendChannelBroadcastCommand.php(134): Symfony\Component\EventDispatcher\EventDispatcher->dispatch(Object(Mautic\ChannelBundle\Event\ChannelBroadcastEvent), 'mautic.channel_...') #19 /var/www/html/vendor/symfony/console/Command/Command.php(298): Mautic\ChannelBundle\Command\SendChannelBroadcastCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #20 /var/www/html/vendor/symfony/console/Application.php(1058): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #21 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(96): Symfony\Component\Console\Application->doRunCommand(Object(Mautic\ChannelBundle\Command\SendChannelBroadcastCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #22 /var/www/html/vendor/symfony/console/Application.php(301): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand(Object(Mautic\ChannelBundle\Command\SendChannelBroadcastCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #23 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #24 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #25 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #26 {main} [] {"hostname":"24beb606f935","pid":111}
[2025-01-07T22:10:03.259208+00:00] mautic.WARNING: Command `mautic:broadcasts:send` exited with status code 1 [] {"hostname":"24beb606f935","pid":111}

If someone has the same issue, make sure to load the environment variables correctly inside the cron file (e.g., /tmp/cron.env) or directly in /opt/mautic/cron/mautic. In my case, the problem was caused by missing AMQP server environment properties.

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