magento-2-smtp icon indicating copy to clipboard operation
magento-2-smtp copied to clipboard

Store transport per store to prevent possible conflicting SMTP options

Open lphilippo opened this issue 3 years ago • 1 comments

Description (*)

This pull requests implements the store specific transports, as related to https://github.com/mageplaza/magento-2-smtp/issues/330

With asynchronous sending enabled and knowing that in our multi-store installation we have separate SMTP settings for each store, we noticed that the wrong SMTP settings were being used (wrong host, username, password) if in a single batch (the cronjob that is used for asynchronous sending) order confirmation emails existed from more than one store.

This seems to happen because although Mageplaza\Smtp\Mail\Rse::getTransport receives the storeId, it only creates a new Transport instance (with the correct SMTP options of the first shop) the first time it is called, instead of the first time per store.

This PR simply adds similar behaviour for the transport instances, as already exists for other variables in this class. With this change, we could verify that each confirmation email used the correct SMTP settings, even if we had multiple stores in a single run.

Fixed Issues (if relevant)

  1. Fixes mageplaza/magento-2-smtp#330

Manual testing scenarios (*)

  1. Setup multiple stores, each with different SMTP options (for example, distinct usernames)
  2. Force multiple order confirmation within one minute, where the order come from different stores.
  3. Verify that each order is actually send out with the correct SMTP options

Questions or comments

This change solved the incorrect behaviour in our installation. We are not aware of any side effects, especially since in most times, only a single store will be present in a batch.

lphilippo avatar Aug 30 '21 09:08 lphilippo

Thanks for your pull request. We'll check this out and let you know when the testing is over.

HuyPhuc98 avatar Sep 13 '21 11:09 HuyPhuc98