- Issue created by @leontin
- π©πͺGermany gbyte Berlin
Let's continue this in 2.x, as Drupal 8/9 is not supported anymore.
I haven't tested the code, but why would different emails use same credentials? The new mail data arrives as the message parameter within the mail() function having new values and so changing of the values should be evaluated anew depending on the message ID?
In the current implementation, the SMTP settings are overridden globally within the request context when
$this->smtpConfig->setSettingsOverride($config)
is called for custom credentials. This override does not automatically reset after each email is sent. Therefore, if multiple emails are sent in a single request, they will all continue to use the overridden credentials unless explicitly reset.The mail() function in this setup doesnβt independently refresh the SMTP configuration for each message based on the message ID. Instead, it relies on the active configuration within the request scope. So, without a manual reset to the default settings after each email, any additional emails sent within the same request will retain the credentials from the first override.
To prevent this unintended persistence, weβd need to explicitly reset the SMTP configuration to its defaults after each email or apply a different instance-based configuration that isolates credentials per email.
Please test and let me know how it went.
- π©πͺGermany gbyte Berlin
Good catch @leontin!
Thanks for the patch; I found it cleaner however to remove the state from the service and just reset the SMTP configuration right after sending each email. This seems to be working but I'd appreciate you double checking. Also if you find the time, feel free to write a test for this.
Automatically closed - issue fixed for 2 weeks with no activity.