Closed BradEstey closed 9 years ago
I'm concerned with backwards-compatibility. This is actually changing what would be returned. I agree what it returns at the moment - 0 or 1 is bad. But if someone checks the response like:
$ok = $mailer->send($message);
if ($ok) {
// ...
}
we would break code in a bad way.
Do you think this would make more sense if it targets the master
branch? I could add it to the 0.4.x milestone.
Here's the other option, which keeps the method returning 1, but now fires a response event that you can listen for containing the Message ID. The rest of the array response isn't really necessary, the Message ID is the big thing that you can then query against the API to get any additional info if needed.
OK, I'll merge this in, try writing a test and will release a 0.1.x release with that. I'll open a new issue for returning the Postmark response in 0.4.
Cheers! :beers:
@BradEstey I actually already released this under 0.1.7 with a test of my own. I was just about to close this as I prepared 0.2.x and 0.3.x releases.
Yay! Thanks. :+1:
I will take your test as well, thanks!
This landed in 0.1.7, 0.2.1 and 0.3.1.
I am looking forward to improve the event system in the transport. It is also currently lacking correct start/stop support.
I've opened #22 for the actual Postmark API response to be returned. Feel free to open a pull request for that against the master branch.
Sorry for popping in here, but I am kinda stuck: How do I listen to this responseReceived event in a Symfony app?
How do I listen to this responseReceived event in a Symfony app?
You will need to access the Swift Mail event dispatcher somehow. I'm not familiar how to do that in Symfony, but you should be able to access it from the Swift Mailer instance in the DIC somehow.
This will make
$mailer->send($message);
return the parsed array response from the Postmark API.Alternatively, I guess a
Swift_Events_ResponseEvent
could be fired to via "responseReceived" with a string representation of the response or just the message ID. Then an instance ofSwift_Events_ResponseListener
can be registered and get that response. Seems like over-engineering a simple problem, but it would avoid changing thereturn 1
response from thesend()
method.Possible use case: An email is sent and the message ID logged, then if Postmark reports a bounce, that log item can be retrieved and updated to reflect the bounced status.