How to send mail using different queues in new Symfony Mail component

631 views Asked by At

I want to configure Symfony Mail component to send different types of emails using different queue priorities. How can I do it?

So far I configured the queues:

framework:
    messenger:
        transports:
            async_low: '%env(MESSENGER_TRANSPORT_DSN_LOW)%'
            async_high: '%env(MESSENGER_TRANSPORT_DSN_HIGH)%'

        routing:
            'Symfony\Component\Mailer\Messenger\SendEmailMessage':  async_high

Then I started the queue with async_high being processed first:

bin/console messenger:consume async_high async_low

Now I would like to send one type of email form higher priority queue than the other:

$this->mailer->send($newsletterEmail); // 10.000 times
$this->mailer->send($resetPasswordEmail); // Triggered after newsletter

Without priorities the password reset would be sent after an hour (after all the newsletters get processed).
How can I send the newsletters using the lower priority queue?

0

There are 0 answers