Symfony mailer : how to reset "All transports failed." error between two emails sending ? #52530
-
I'm using Symfony Mailer with the I have a use case where a customer needs to send 4 emails in a row from our application. All four emails are sent to a single recipient, one after the other synchronously. This works well with Symfony Mailer if all the emails can be sent, but if one of the emails cannot be sent, the rest of the emails are not sent with the error message Example:
My expected result is that emails 1, 3 and 4 are sent, but email 2 fails. The validity of all emails is checked before sending with the https://github.com/egulias/EmailValidator library, but as [email protected] is considered valid, the application tries to send the email. Is there any way of "resetting" the transport failure options between two email sending ? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
Please always include Component version in use.
I don't think this is what happens. However ever if you handle this exception somehow or move to the async handling then RaoundRobinTransport still will cause problem because there is 60 seconds freeze for every transport that fails. This could be made configurable on the Symfony side. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your answer, and sorry about the missing details. I am using SF5.4.31. All the email logic is well encapsulated within a try/catch block with logs that provide insight into the fact that subsequent emails are not sent due to the failure of the 2nd email. Here is an idea of the code I am using:
The first email is well sent, the others all failed with error log "Error when sending email [No transports found.]". If [email protected] recipient is replaced with another valid email, all the emails are well sent. Your ideas are very welcome. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your answer. I wrote this example too quickly this morning and the And you are absoluty right about the error messages : nice guess ! I found the parameter in the And because Thank you for the explaination and opening #52551 |
Beta Was this translation helpful? Give feedback.
-
I confirm that sleeping for 61 seconds in the catch allows sending the next emails. |
Beta Was this translation helpful? Give feedback.
-
FYI #54939 |
Beta Was this translation helpful? Give feedback.
I bet it's 3rd and 4th email that fail with error log
Error when sending email [No transports found]
." and 2nd fails withError when sending email [All transports failed]
.Now that we know you have
try..catch
block then this paragraph in my answer applies:Unfortunatelly it's not configurable at the moment. I've opened an issue for this #52551
P…