infrangible / m2-smtp
Sends all store emails through your own SMTP servers, with a backup server, an automatic fallback, test mails and a log of every sent email.
Package info
github.com/infrangible-dev/m2-smtp
Type:magento2-module
pkg:composer/infrangible/m2-smtp
Requires
- php: >=8.1
- ext-filter: *
- ext-mbstring: *
- fewedev/base: ~2.4.1
- infrangible/m2-backend-widget: ~4.0.7
- infrangible/m2-core: ~5.0.8
- infrangible/m2-foundation: ~3.0.2
- infrangible/m2-simple-mail: ~2.0.1
- magento/framework: ~103.0.6
- magento/module-backend: ~102.0.0
- magento/module-config: ~101.2.0
- magento/module-cron: ~100.4.0
- magento/module-eav: ~102.1.0
- magento/module-email: ~101.1.0
- magento/module-store: ~101.1.0
- psr/log: ~2.0.0||~3.0.0
Requires (Dev)
- infrangible/phpstan-magento: ~1.2.0
Suggests
- laminas/laminas-mail: Sends the emails of Magento 2.4.7 and older, which install it
- symfony/mailer: Sends the emails of Magento 2.4.8 and newer, which install it
- symfony/mime: Builds the emails of Magento 2.4.8 and newer, which install it
Provides
None
Conflicts
None
Replaces
None
README
Sends the emails of the store through your own SMTP servers: a main server and a backup server, with an automatic fallback to Magento's own mail sending. Every email is logged with its addresses, subject, status, the server that sent it and the errors of the servers that failed. The configuration gets a button to send a test email with the entered settings before they are saved.
Configuration
Stores > Configuration > Infrangible Solutions > SMTP (default, website and store view scope):
- General
- Enable: sends the emails through the enabled servers and logs them. Without enabled servers, Magento sends them as usual and they are only logged. Disabled, the module neither sends nor logs.
- Allow System Fallback: if no server could send an email, Magento sends it as usual. Without the fallback, the email fails with an error.
- Server Priority #1 and Server Priority #2: the servers, tried in this order.
- Host and Port (usually 587 for STARTTLS and 465 for SSL/TLS)
- Encryption: None, STARTTLS or SSL/TLS
- Authentication: None, PLAIN, LOGIN or CRAM-MD5, with User Name and Password (stored encrypted)
- Log (default scope)
- Store Content: stores the content of the emails in the log. The content contains personal data of the customers; switching it off removes the stored content with the nightly cleanup.
- Retention in Days: log entries older than this are deleted every night (default 90, 0 keeps them).
- Test Mail: choose a server, a sender identity of the store and one or more receivers (separated by semicolons),
then click Send. The email is sent through the selected server only, with the settings entered on the page, so
they can be tested before saving. The page shows whether the email was sent, or the error of the server. Only admin
users who may change the configuration of SMTP (ACL resource
Infrangible_Smtp::config_infrangible_smtp) can send it.
Magento's setting Set Return-Path (Stores > Configuration > Advanced > System > Mail Sending Settings) applies to the emails sent through the servers as well.
Log
Infrangible > SMTP > Log lists the sent emails with their status (Sending, Sent, Error), the server that sent
them (Server Priority #1, Server Priority #2 or Magento) and the errors of the servers that failed before. The view of
an entry shows the stored content; HTML emails are shown in a sandbox, without scripts. The log needs the ACL resource
Infrangible_Smtp::smtp_log.
Magento versions
Magento 2.4.6 and 2.4.7 build the emails with Laminas Mime, the module sends them with Laminas Mail. Magento 2.4.8 and newer build them with Symfony Mime, the module sends them with Symfony Mailer. Both libraries come with Magento.
Requirements
- Magento Open Source or Adobe Commerce 2.4.6 or newer
- PHP 8.1 or newer
Installation
composer require infrangible/m2-smtp bin/magento module:enable Infrangible_Smtp bin/magento setup:upgrade
In production mode, also run bin/magento setup:di:compile.
License
Infrangible SMTP is licensed under the MIT License - see the LICENSE file for details.