-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Symfony->Mailer additional Method: EsmtpTransport->setAuthenticators (because of Microsoft Authentification with OAuth for SMTP sending is slow) #49701
Comments
This is the part I do not understand. Why does the transport have to wait for a timeout? Is that something that can be improved? |
What I did see, the Mailer simply tries all possible Authenticators in the sequence like in the One Solution is to set the $this->authenticators with only the XOAuth2Authenticator. Another really user-/developerfriendly solution would maybe be, if the EsmtpTransport checks if in the password-field is an access token (they have a special format) and than automaticly only uses the XOAUTH2Authenticator. (but not sure if this is possible, think it should be, but didnt look over the code again) I think another solution is not possible, because the mailer can't know which of the possible authenticationmethods it should prefer, you have to tell him which Authentication he has to use. I try to provide additional context, like Protocol. That you see, what happens. |
Here the Client/Server-Communication while sending the Mail. In line 21 the Microsoft server says which authentication methods it supports. In line 26-33 you see that the LoginAuthenticator is used. So the time for the LoginAuthenticator is mostly bad because of these too long answers of the Microsoftservers (1.5s + 7s + 5s). So for that you can't do anything or fix anything. But we could avoid these slow answers, when we can avoid the LoginAuthenticator, and only use the XOAuth2Authenticator. After that, in Lines 34-44, the Mailer tries the XOAuth2Authenticator and sends the email.
(All Data are anonymized, including access token) |
Reading the code I do not really see a reason why the code should hang there. Can you try debugging the execution using Xdebug or some other debug? |
Okay I updated the comment above, with the correct times and statements. Im sorry for first misleading statement. Now its correct and is also plausible. |
I recently experienced the same issue and I confirm it is slow. Problem here is that the Azure server takes a long time to execute first failing I can work on this part if everyone agrees to add this ability via a simple setter. |
Done in #49900, waiting for reviews. |
… (cedric-anne) This PR was merged into the 6.3 branch. Discussion ---------- [Mailer] Allow overriding default eSMTP authenticators | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #49701 | License | MIT | Doc PR | symfony/symfony-docs#... TODO SMTP authentication using OAuth token on Azure servers is really long, due to high latency responses from the SMTP server (probably to prevent brute-force attacks). Indeed, a `AUTH LOGIN` command is sent first, and have to wait for about 5 seconds get the error response back. Then a `RSET` command is sent and also have to wait for about 5 seconds get a response back. The `AUTH XOAUTH2` command is then sent and all is fast after that. Adding the ability to override default eSMTP authenticators will permit developers to explicitely define that only `XOAUTH2` authenticator has to be used, to prevent high latency in SMTP authentication. I will update the documentation once new methods signatures will be validated. Commits ------- bb656d0 [Mailer] Allow overriding default eSMTP authenticators
Description
I work with the Symfony/Mailer 5.4.7 and can send E-Mails with Microsoft Outlook and XOAuth2.
But the Problem is, its very slow.
This happens because Microsoft provides the possibility for
LoginAuthenticator and XOAUTH2Authenticator in the protocoll. And in the
symfony/mailer/Transport/Smtp/EsmtpTransport.php:38
constructor are the authenticators set to use both. What understandable is when you want to support most used Authenticators.But through this order, it trys always at first the LoginAuthenticator and waits for a timeout, and after
that it uses the XOAUTH2Authenticator.
I copied the EsmtpTransport class and only changed the $this->authenticators, to hold only the XOAuth2Authenticator.
There is a difference in time for sending Mails between 22s with both Authenticators, and 5s with my own EsmtpTransport class (where I set the authenticators to use only XOAuth2Authenticator).
Because I dont get automatic securityfixes/bugfixes with my own EsmtpTransport class. I want to ask if we can create a possibility to set the $this->authenticators?
What I see there is only a possibility to add additional authenticators.
Example
No response
The text was updated successfully, but these errors were encountered: