Skip to content

[Mailer] Sender address from configuration not used when using aysnc transport #59812

Closed
@gremo

Description

@gremo

Symfony version(s) affected

7.2

Description

Cannot send email messages using the async transport and the sender address configuration. Exception thrown:

"An email must have a "From" or a "Sender" header."

How to reproduce

Set the sender address in the configuration:

framework:
    mailer:
        dsn: '%env(MAILER_DSN)%'
        envelope:
            sender: no-reply@example.com
        headers:
            From: 'Example <no-reply@example.com>'

Send an email without using any transport (sync sending): OK

Send an email using the async transport: KO

Error thrown while handling message Symfony\Component\Mailer\Messenger\SendEmailMessage. Sending for retry #1 using 1060 ms delay. Error: "An email must have a "From" or a "Sender" header." {"class":"Symfony\Component\Mailer\Messenger\SendEmailMessage","message_id":77,"retryCount":1,"delay":1060,"error":"An email must have a "From" or a "Sender" header.","exception":"[object] (Symfony\Component\Mime\Exception\LogicException(code: 0): An email must have a "From" or a "Sender" header. at /app/vendor/symfony/mime/Message.php:132)"} []

Async transport configuration:

framework:
    messenger:
        # Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
        failure_transport: failed

        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

Possible Solution

No response

Additional Context

The EnvelopeListener which I suppose is responsible of setting the sender is actually called even using the async transport.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy