maxcode / module-store-smtp
EN: Makes the native SMTP settings of Magento 2.4.8+ apply per store view: every transactional email is sent with the SMTP server of its own store, also when it is sent from the admin, by cron or asynchronously. FR : Applique par vue magasin les réglages SMTP natifs de Magento 2.4.8+ : chaque e-mail
Package info
github.com/eBusiness360/module-store-smtp
Type:magento2-module
pkg:composer/maxcode/module-store-smtp
Requires
- php: ~8.2.0||~8.3.0||~8.4.0
- magento/framework: ^103.0.8
- magento/module-email: ^101.1.8
- magento/module-store: *
- maxcode/module-core: ^1.0.11
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
English · Français
Magento 2.4.8 has a native SMTP transport (Stores > Configuration > Advanced > System > Mail Sending Settings) and its fields can be set per store view. But the transport reads them for the store that happens to be active when the email leaves, not for the store the email belongs to:
| Email sent… | Native 2.4.8 uses the SMTP of… |
|---|---|
| from the storefront of store view B | store view B ✔ |
| from the admin (invoice, credit memo, shipment, "Send Email", resend) | the default scope ✘ |
| by cron or asynchronously | the default store view ✘ |
In a multi-store shop with one SMTP account per brand, admin and cron emails of store view B leave through the server of the default scope, with the sender address of store B: SPF and DMARC fail and Gmail rejects them.
What it does
- Every email built by Magento's
TransportBuilderis sent with thesystem/smtp/*settings of its own store view: transport, host, port, username, password, auth, SSL, Return-Path, and "Disable Email Communications". - The store comes from what Magento already gives the builder:
setTemplateOptions(['store' => …]), or the sender scopesetFromByScope($from, $storeId). - No new screen, nothing to configure: it uses the native fields. A short note under Transport says they now apply per store view.
- An email without a store, or for the admin store, behaves exactly as without the module.
- No core override, no database table: one plugin on
TransportBuilder, one configuration reader given to the native transport, and the native "disable" plugin replaced by a store-aware one.
Requirements and installation
Magento Open Source / Adobe Commerce 2.4.8 or later, PHP 8.2 to 8.4.
composer require maxcode/module-store-smtp bin/magento module:enable Maxcode_StoreSmtp bin/magento setup:upgrade
Tests
- Unit:
vendor/bin/phpunit -c app/code/Maxcode/StoreSmtp/dev/phpunit.xml(from the Magento root). - Integration: see
dev/phpunit.integration.xml.
Français
Magento 2.4.8 a un transport SMTP natif (Magasins > Configuration > Avancé > Système > Paramètres d'envoi des e-mails), réglable par vue magasin. Mais il lit ces réglages pour la boutique active au moment de l'envoi, pas pour la boutique de l'e-mail : les e-mails envoyés depuis l'admin (facture, avoir, expédition, renvoi), par le cron ou en asynchrone partent par le SMTP par défaut, avec l'expéditeur de la boutique B. SPF et DMARC échouent et Gmail les refuse.
Ce module fait partir chaque e-mail avec les réglages system/smtp/* de sa vue magasin (transport, hôte,
port, identifiant, mot de passe, authentification, SSL, Return-Path, « Désactiver les communications par
e-mail »). La boutique est celle que Magento donne déjà au constructeur de message (setTemplateOptions ou
setFromByScope). Aucun nouvel écran, aucun réglage, aucune réécriture du cœur ; sans boutique connue, le
comportement natif est conservé.
Licence : voir le fichier LICENSE.