Perfect Square
Perfect Square

Reputation: 1418

Consuming emails async in Symfony 5

I use Symfony 5 messanger to handle emails sending in async way. I have:

Current situation: sending emails to queue works - using mailer results in inserting record in database table messanger_messages.

Problem: If I understood docs correctly, for async emails processing, first emails are queued into DB (for my case) and they are then sent one by one with command php bin/console messenger:consume -vv async. Unfortunatelly executing this command does not result in emails being sent. Records in database remain the same, they do not fall into failed category and no emails are generated.

To be sure that sending configuration is correct I switched to sync method and in this case emails are immediately generated and sent. So my question is wheter there is another step which should be done to make queued emails to be consumed eg. writting custom sending handler (I assumed that messanger:consume command will do this for me) or if there is any other part of this process I missed which causes that queued emails are not consumed.

Upvotes: 0

Views: 2137

Answers (1)

Perfect Square
Perfect Square

Reputation: 1418

I figured it out so adding answer for posterity. Command messanger:consume was not working due to an issue in server configuration.

Messages inserted in database were inserted using current datetime based on timezone set in apache php.ini. As it happens php has second, different php.ini configuration file applicable to CLI commands only.

Executing messanger:consume in CLI made script to use different timezone and thus causing query used to fetch messages in queue to return empty result (conditions could never be met).

Updating and synchronizing timezones in both php.ini files solved the issue and made mechanism to consume messages from queue.

You can locate console php.ini using php --ini in CLI.

Upvotes: 1

Related Questions