magento-2-smtp
magento-2-smtp copied to clipboard
Multiple stores with different SMTP options fail when `Asynchronous sending` is enabled
Preconditions (*)
- Magento 2.4.2
- Turn on
Asynchronous sending
Steps to reproduce (*)
- Configure different SMTP options for different stores
- Schedule a single email for two different stores.
Expected result (*)
- Two emails being sent when the cron runs, each with their own SMTP options.
Actual result (*)
- Both emails are being sent with the SMTP options of the first email.
Additional information
When during a single cron run, multiple emails are processed from different stores (with different SMTP options), the SMTP options are not being adjusted on the second or next message.
In Mageplaza\Smtp\Mail\Rse\Mail::getTransport($storeId)
the $this->_transport
is not being reinstantiated, when it's called with another store-ID than as used for the existing value. The store ID is only being used during actual initialisation, as only happens during the first request.
If we adjust the code to force $this->_transport
to be reinstantiated every time it's called (better compare or cache it), the expected behaviour is achieved, as both emails are processed with their correct SMTP settings.
Hi,
This is my first time having this problem so I don't know how to reproduce the problem yet. Can you please provide me with a screen shot that reproduces the issue in detail so I can check it out? Thank you!
Hello @HuyPhuc98
Screenshots will probably not be very helpful here. I've created a PR containing our local fix, which should explain the issue much quicker, I think:
https://github.com/mageplaza/magento-2-smtp/pull/332
We simply saw that wrong SMTP settings were applied to emails, when we had a lot of confirmation emails (of different shops). This had the undesired effect that although the emails were being delivered, the wrong SMTP server was exposed in some emails. If you would like more specific information, please let me know.
Thank you very much for your feedback. We will check your fix.