title: Consuming emails async in Symfony 5
body: <p>I use Symfony 5 messanger to handle emails sending in async way. I have:</p>
  <ul>
  <li><p>email DNS configured in <strong>.env</strong></p>
  <p><code>MAILER_DSN=smtp://localhost</code></p>
  </li>
  <li><p>messanger transport DNS in <strong>.env</strong> (I use database to store emails queue)</p>
  <p><code>MESSENGER_TRANSPORT_DSN=doctrine://default</code></p>
  </li>
  <li><p>transports and routing in <strong>messenger.yaml</strong></p>
  <pre><code>  serializer:
        default_serializer: messenger.transport.symfony_serializer
  
    transports:
        # https://symfony.com/doc/current/messenger.html#transport-configuration
        async: '%env(MESSENGER_TRANSPORT_DSN)%'
        failed: 'doctrine://default?queue_name=failed'
  
        # sync: 'sync://'
  
    routing:
        # Route your messages to the transports
        # 'App\Message\YourMessage': async
        'Symfony\Component\Mailer\Messenger\SendEmailMessage':  async
  </code></pre>
  </li>
  </ul>
  <p><strong>Current situation:</strong> sending emails to queue works - using mailer results in inserting record in database table <em>messanger_messages</em>.</p>
  <p><strong>Problem:</strong> 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 <code>php bin/console messenger:consume -vv async</code>. Unfortunatelly executing this command does not result in emails being sent. Records in database remain the same, they do not fall into <em>failed</em> category and no emails are generated.</p>
  <p>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 <code>messanger:consume</code> 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.</p>