Closed pminetti closed 1 week ago
Hi !
I had the same issue here, can't figure why.
And I solve it with the help of your message @pminetti ! Thanks !
So sometimes, processSendingPasswordResetEmail is working better with TransportInterface than with MailerInterface.
Hey just wanted to say, it's a year later and I had the same exact problem and the same exact solution worked! Swap MailerInterface with TransportInterface and everything started working.
In fact, something weird happened, in case it helps pinpoint the issue here are the details:
I installed the reset-password bundle and it was working perfectly in my dev branch, the emails were showing up in mailtrap almost instantly.
Swapped to production, uploaded the changes, and it didn't work at all (i'd click send email, but no email came through).
I checked and triple checked every changed file, made sure everything was uploaded, cleared cache in the server, even stopped and started the mailer worker in -vv mode and no emails were showing up on the logs when trying to reset password (all other email functionalities were woking correctly). So I went to bed.
This morning I saw an email from last night with my expired reset password link.
Then I saw this issue, changed Mailer for Transport, tested and the email came through in seconds.
Hope the extra info helps, and thanks @pminetti for the unexplicable yet effective fix!
This morning I saw an email from last night with my expired reset password link
So the email was actually sent by MailerInterface
but it was sent with the delay? Am I understand it correct? Sounds like a possible misconfiguration of the Messenger. Do you use Messenger in your app?
I think the problem is that MailerInterface can handle async and sync modes. and by default is using async. As I can read in the documentation, if my dsn is smtp, the sync mode is enabled, so I don't need to configure nothing more.
@pminetti Could you please link to the docs where you see this?
Hello guys! Thank you for taking the time to report it.
I did some research on this issue. Yes, that's true, if you're using MailerInterface
- it indeed may add emails to the Messenger's queue instead of sending it immediately. And if you change to TransportInterface
- it will send immediately. But in order to add the email to the queue - you need to have Messenger Component installed and configured in your app. Moreover, you have to have Messenger routing enabled for the SendEmailMessage
to have it handled async, something like this:
framework:
messenger:
transports:
async: '%env(MESSENGER_TRANSPORT_DSN)%'
routing:
'Symfony\Component\Mailer\Messenger\SendEmailMessage': async
If you don't have that SendEmailMessage: async
- the email will not be sent via Messenger, i.e. it will be sent immediately anyway.
So, I believe this issue comes to your specific configuration. And if you're using Messenger in your app - I suppose you're aware of how it works and how to use it correctly. You just need to have the worker running in the background to consume the messages in the queue and send the emails. Even with handling emails via Messenger, you can achieve the email being sent in a few seconds, but of course, it depends on your website load, i.e. how many messages you have in the queue. But probably if you have a high-load project - you would want to send it async instead of sending it immediately anyway :)
So I'm closing this issue - IMO nothing to fix here and everything works as expected, that's just a user config problem. If you still have this issue but don't have Messenger installed in your app - than yes, it would be weird I think. But I can't reproduce it myself, so please, create a simple bug reproducer so that we could take a look at your specific case. Here's the explanation of how to create the reproducer: https://symfonycasts.com/blog/symfony-reproducer
Cheers!
Hi,
My MAILER_ DSN is smtp://user:pass@domain:port
When I use the original function processSendingPasswordResetEmail with MailerInterface, no email is sent, but if I change to TransportInterface, the email is sent.
I think the problem is that MailerInterface can handle async and sync modes. and by default is using async. As I can read in the documentation, if my dsn is smtp, the sync mode is enabled, so I don't need to configure nothing more.
I can't figure what I'm missing.
Thanks