Skip to content

Allow to add new headers to a SentMessage object #45871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
driesvints opened this issue Mar 28, 2022 · 7 comments
Open

Allow to add new headers to a SentMessage object #45871

driesvints opened this issue Mar 28, 2022 · 7 comments

Comments

@driesvints
Copy link
Contributor

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.

@driesvints driesvints changed the title Allow to add new headers to a SentMessage Allow to add new headers to a SentMessage object Mar 28, 2022
@driesvints
Copy link
Contributor Author

Please note that I'm still not 100% sure this is needed. Would love to get some feedback on this here first to make sure nothing important is missed.

@kbond
Copy link
Member

kbond commented Mar 28, 2022

I agree with your conclusions above. Feels like maybe SentMessage needs a generic key/value store of data to be populated by the transport. There could be other useful data a transport could provide.

protected function doSend(SentMessage $message): void
{
    // Perform sending...
    $message->addInfo('SES-Message-ID', $result->getMessageId());
    $message->addInfo('some-other-useful-metric', $result->somethingElse());
}

// somewhere else
$sentMessage->getInfo('SES-Message-ID'); // "the message id"

@xabbuh xabbuh added the Mailer label Mar 29, 2022
@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@driesvints
Copy link
Contributor Author

Hi @kbond, was this ever added? Someday we'd love to move to the Amazon Mailer but for now it's preventing us to do that.

@carsonbot carsonbot removed the Stalled label Oct 31, 2022
@kbond kbond added this to the 6.3 milestone Oct 31, 2022
@kbond kbond self-assigned this Oct 31, 2022
@kbond
Copy link
Member

kbond commented Oct 31, 2022

Hey Dries, I don't think so but I'll take a fresh look for 6.3.

@driesvints
Copy link
Contributor Author

Thanks!

@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@kbond kbond added Keep open and removed Stalled labels May 3, 2023
@nicolas-grekas nicolas-grekas removed this from the 6.3 milestone May 25, 2023
@kbond kbond added Stalled and removed Keep open labels May 17, 2025
@kbond kbond removed their assignment May 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
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