The Wayback Machine - https://web.archive.org/web/20250613232501/https://github.com/symfony/symfony/issues/45871
Skip to content

Allow to add new headers to a SentMessage object #45871

Open
@driesvints

Description

@driesvints

Description

In laravel/framework#41615 we restored some old behavior in our SES Transport that adds the X-Message-ID and X-SES-Message-ID headers which contain the value of the message ID generated by SES (not to be confused with the one from Symfony Mailer).

Now, we solved this by adding the headers to the original message which is wrapped in the SentMessage object that's passed to the doSend method of the transport. However, this doesn't seems the correct place to me as the original message should represent the message that's been composed before it's sent off to Symfony Mailer. Modifying it after a send has been performed feels wrong. I believe the correct place to add the headers is to add them to the SentMessage object. There isn't a way to do this however.

Right now, the symfony/amazon-mailer transport solves this by calling the setMessageId method on the SentMessage object. However, I feel this is wrong too. This basically replaces the Symfony Mailer generated Message ID with the SES Message ID one. I think it's important that both still remain available because you won't be able to match the messages anymore without the original Symfony Message ID.

I've added an example below but I'm more than happy if someone has ideas about why this wouldn't be wanted.

Also pinging @kbond because we were recently in touch about the SES Transport. Right now, there isn't a way for us to move to the Symfony Amazon Mailer since it doesn't provides the X-Message-ID and X-SES-Message-ID headers.

Example

Some API like the following is needed I think:

protected function doSend(SentMessage $message): void
{
    // Perform sending...
    $message->addMessageId('X-Message-ID', $result->getMessageId());
    $message->addMessageId('X-SES-Message-ID', $result->getMessageId());
}

This would allow to add additional message ID's to the SentMessage.

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