-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] Add a way to retrieve the SentMessage object #35670
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
Comments
I just encountered this same issue. The docs here clearly show the top-level send() method directly returning an instance of SentMessage, but the actual code doesn't do that, it just throws the transport's result away. Perhaps Symfony\Component\Mailer\Mailer::send() should be changed from this:
To this:
|
I don't think it is the right way to do it because it will only handle the case when the mail is not sent async. I think an event throw by the |
Yeah, I get that it would be different for async/sync, but the feature is documented. So, which is wrong, the code or the docs? shrug Maybe implement both methods? |
As of #36424 (5.1), you can now get the sent message when it was handled by messenger. |
Hi, could anyone explain how #36424 allows us to get the returned MessageId when sending an email following the instructions here - https://symfony.com/doc/current/mailer.html, I don't see how this relates to MessageHandler? |
@altcom-neil Did you ever find a solution to your issue? I ended up using the Is there a way to get the SentMessage object using async @fabpot? |
@reubenporterjisc no we were working through the proof of concept so it was more important to get past this stage than spend any more time so I added a custom version of the Mailer class that saves the SentMessage response to a class var and then adds a method to retrive it: `
} No idea what to do about the rest of the code and how to get to the MessageId if $this->bus is not null but when doing the basic sending using
p.s. no idea how to get the code formatter to work on here properly either but you can get the jist |
Uh oh!
There was an error while loading. Please reload this page.
Description
With this PR: #33967
The messageId provided by the providers is stored in the SentMessage object that is returned by the TransportInterface
I can't find a way to get it (the SentMessage) using directly the MailerInterface as:
Is it possible to add an Event that is sent with a way to retrieve the final messageId?
Some providers use this messageId to deliver statistics information about the mails (It has soft/hard bounced? The mail is opened? / ...) so I want to be able to store it somehow
If there is no way to get it actually, I could try to provide a PR to add this feature.
The text was updated successfully, but these errors were encountered: