Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queued messages are sent multiple times under certain conditions #13070

Closed
1 task done
patrykgruszka opened this issue Dec 12, 2023 · 2 comments · Fixed by #13071
Closed
1 task done

Queued messages are sent multiple times under certain conditions #13070

patrykgruszka opened this issue Dec 12, 2023 · 2 comments · Fixed by #13071
Labels
bug Issues or PR's relating to bugs email Anything related to email
Milestone

Comments

@patrykgruszka
Copy link
Member

Mautic Version

5.0.x series

PHP version

8.0

What browsers are you seeing the problem on?

Not relevant

What happened?

The emails from queue could be sent multiple times to the same contact if there is an exception thrown during the batch processing.

How can we reproduce this issue?

  1. Set the Frequency rule in the Mautic settings to 1 message per day.
  2. Create a segment with some contacts, one contact should have an empty first name (null in the database) and at least one company.
  3. Create and send an email to the segment, add the {contactfield=firstname} to the email content
  4. Clone the email and send it again - it should be added to the message queue because of the limit.
  5. After 24 hours, run the command to send the queue ddev exec php bin/console mautic:messages:send.
  6. The error should be thrown while executing this command.

Batch emails are dispatched and the queue table entries are modified only after the successful sending of all emails. In the event of an error during the batch process, the queue remains unaltered even though certain emails may have been sent.

Relevant log output

console.CRITICAL: Error thrown while running command "mautic:messages:send". Message: "Warning: Undefined array key "firstname"" {"exception":"[object] (ErrorException(code: 0): Warning: Undefined array key \"firstname\" at /var/www/html/app/bundles/LeadBundle/Helper/TokenHelper.php:81)
[stacktrace]
#0 /var/www/html/app/bundles/LeadBundle/Helper/TokenHelper.php(43): Mautic\\LeadBundle\\Helper\\TokenHelper::getTokenValue(Array, 'firstname', '')
#1 /var/www/html/app/bundles/LeadBundle/EventListener/EmailSubscriber.php(66): Mautic\\LeadBundle\\Helper\\TokenHelper::findLeadTokens('t1208<!DOCTYPE ...', Array)
#2 /var/www/html/vendor/symfony/event-dispatcher/Debug/WrappedListener.php(118): Mautic\\LeadBundle\\EventListener\\EmailSubscriber->onEmailGenerate(Object(Mautic\\EmailBundle\\Event\\EmailSendEvent), 'mautic.email_on...', Object(Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher))
#3 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(230): Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener->__invoke(Object(Mautic\\EmailBundle\\Event\\EmailSendEvent), 'mautic.email_on...', Object(Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher))
#4 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(59): Symfony\\Component\\EventDispatcher\\EventDispatcher->callListeners(Array, 'mautic.email_on...', Object(Mautic\\EmailBundle\\Event\\EmailSendEvent))
#5 /var/www/html/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php(154): Symfony\\Component\\EventDispatcher\\EventDispatcher->dispatch(Object(Mautic\\EmailBundle\\Event\\EmailSendEvent), 'mautic.email_on...')
#6 /var/www/html/app/bundles/EmailBundle/Helper/MailHelper.php(1515): Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher->dispatch(Object(Mautic\\EmailBundle\\Event\\EmailSendEvent), 'mautic.email_on...')
#7 /var/www/html/app/bundles/EmailBundle/Model/SendEmailToContact.php(403): Mautic\\EmailBundle\\Helper\\MailHelper->dispatchSendEvent()
#8 /var/www/html/app/bundles/EmailBundle/Model/SendEmailToContact.php(220): Mautic\\EmailBundle\\Model\\SendEmailToContact->sendStandardEmail()
#9 /var/www/html/app/bundles/EmailBundle/Model/EmailModel.php(1540): Mautic\\EmailBundle\\Model\\SendEmailToContact->send()
#10 /var/www/html/app/bundles/EmailBundle/EventListener/MessageQueueSubscriber.php(72): Mautic\\EmailBundle\\Model\\EmailModel->sendEmail(Object(Mautic\\EmailBundle\\Entity\\Email), Array, Array)
#11 /var/www/html/vendor/symfony/event-dispatcher/Debug/WrappedListener.php(118): Mautic\\EmailBundle\\EventListener\\MessageQueueSubscriber->onProcessMessageQueueBatch(Object(Mautic\\ChannelBundle\\Event\\MessageQueueBatchProcessEvent), 'mautic.process_...', Object(Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher))
#12 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(230): Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener->__invoke(Object(Mautic\\ChannelBundle\\Event\\MessageQueueBatchProcessEvent), 'mautic.process_...', Object(Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher))
#13 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(59): Symfony\\Component\\EventDispatcher\\EventDispatcher->callListeners(Array, 'mautic.process_...', Object(Mautic\\ChannelBundle\\Event\\MessageQueueBatchProcessEvent))
#14 /var/www/html/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php(154): Symfony\\Component\\EventDispatcher\\EventDispatcher->dispatch(Object(Mautic\\ChannelBundle\\Event\\MessageQueueBatchProcessEvent), 'mautic.process_...')
#15 /var/www/html/app/bundles/ChannelBundle/Model/MessageQueueModel.php(376): Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher->dispatch(Object(Mautic\\ChannelBundle\\Event\\MessageQueueBatchProcessEvent), 'mautic.process_...')
#16 /var/www/html/app/bundles/ChannelBundle/Model/MessageQueueModel.php(265): Mautic\\ChannelBundle\\Model\\MessageQueueModel->dispatchEvent('process_batch_m...', NULL, false, Object(Mautic\\ChannelBundle\\Event\\MessageQueueBatchProcessEvent))
#17 /var/www/html/app/bundles/ChannelBundle/Model/MessageQueueModel.php(188): Mautic\\ChannelBundle\\Model\\MessageQueueModel->processMessageQueue(Array)
#18 /var/www/html/app/bundles/ChannelBundle/Command/ProcessMarketingMessagesQueueCommand.php(69): Mautic\\ChannelBundle\\Model\\MessageQueueModel->sendMessages(NULL, NULL)
#19 /var/www/html/vendor/symfony/console/Command/Command.php(298): Mautic\\ChannelBundle\\Command\\ProcessMarketingMessagesQueueCommand->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\\ProcessMarketingMessagesQueueCommand), 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\\ProcessMarketingMessagesQueueCommand), 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}

Code of Conduct

  • I confirm that I have read and agree to follow this project's Code of Conduct
@patrykgruszka patrykgruszka added bug Issues or PR's relating to bugs needs-triage For new issues/PRs that need to be triaged email Anything related to email and removed needs-triage For new issues/PRs that need to be triaged labels Dec 12, 2023
@escopecz escopecz added this to the 5.0.0 milestone Jan 9, 2024
Copy link
Contributor

github-actions bot commented Jan 9, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If this issue is continuing with the lastest stable version of Mautic, please open a new issue that references this one.

@mautibot
Copy link

This issue has been mentioned on Mautic Forums. There might be relevant details there:

https://forum.mautic.org/t/mautic-campaign-sending-multiple-marketing-emails-to-the-same-contacts/31336/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues or PR's relating to bugs email Anything related to email
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants