Magento SMTP with the free Mageplaza SMTP extension
Make Magento 2.4.9 send its emails through your mail provider: install the free Mageplaza SMTP extension with Composer, fill in the SMTP settings, send a test email, save the settings, and follow a real store email into the inbox and the email log.
Downloads
The settings script has placeholder values (smtp.example.com, store@example.com). Put in your mail provider’s values before you run it. It asks for the password, so no password is in the file.
Why SMTP
Without SMTP, Magento hands its emails to the server’s own mail program (sendmail). Those emails often land in spam or never arrive, because the server is not an authorised sender for your domain. With SMTP, your mail provider sends them, and its SPF and DKIM records for your domain let them reach the inbox.
Magento 2.4.9 has a basic SMTP option too: Stores › Configuration › Advanced › System › Mail Sending Settings › Transport. The free Mageplaza SMTP extension adds a Test Now button, ready-made settings for common providers, an email log with resend, and a developer mode that stops all emails on test copies.
Installing Mageplaza SMTP
The Composer package is mageplaza/module-smtp (version 4.7.27 in the video). Composer also installs mageplaza/module-core (1.6.0). Both are free, and both installed on Magento 2.4.9 with PHP 8.5. Run Composer as the user that owns the Magento files, not as root.
#!/bin/bash
# MageBooster lesson 6: install the free Mageplaza SMTP extension (Magento 2.4.9, production mode).
# Composer asks for your repo.magento.com keys (auth.json) if they are not set yet.
set -e
cd /var/www/magento
m() { sudo -u magento bin/magento "$@"; }
m maintenance:enable
sudo -u magento composer require mageplaza/module-smtp
m module:enable Mageplaza_Core Mageplaza_Smtp
m setup:upgrade
m setup:di:compile
m setup:static-content:deploy -f en_US en_GB de_DE
m maintenance:disable
m cache:flush
# production mode: OPcache keeps the old code until PHP-FPM reloads
sudo systemctl reload php8.5-fpm
setup:di:compile, or OPcache keeps the old code. Deploy the static files for every locale your admin and store views use (in the video: en_US for the admin, en_GB and de_DE for the store views).The SMTP settings
Stores › Configuration › Mageplaza Extensions › SMTP:
| Field | Value in the video | On a live store |
|---|---|---|
| Enable Mageplaza SMTP | Yes | Yes |
| Log Emails | Yes | Yes: every email is saved in the Email Log |
| Clean Email Log Every | 10 (days) | How many days the log is kept; empty or 0 = never cleaned |
| Host | 127.0.0.1 (Mailpit on the test server) | Your provider’s SMTP host; Load Settings fills it for Gmail, Microsoft 365, Zoho and others |
| Port | 1025 | 587 with TLS, or 465 with SSL |
| Protocol | None | TLS or SSL |
| Authentication | LOGIN | LOGIN (or what your provider asks for) |
| Username | store@example.com | Usually your email address |
| Password | a dummy (Mailpit accepts any) | Your SMTP password, or an app password |
| Return-Path Email | empty | Where bounced emails go; empty = the sender address |
bin/magento config:set as below.Sending a test email
Open Send Test Email under SMTP Configuration Options. Send From is a sender identity (General Contact in the video), Send To is your own address. Test Now uses the values in the form, so it works before you save them. “Sent successfully! Please check your email box.” means the SMTP server accepted the email.
On the test server in the video, Mailpit catches every email (SMTP on 127.0.0.1:1025, web inbox on port 8025), so nothing leaves the server.
Saving the settings
As the Magento file owner, set the same values with bin/magento config:set, then flush the cache. The password is stored encrypted.
#!/bin/bash
# MageBooster lesson 6: Mageplaza SMTP settings with bin/magento config:set.
# Put in your mail provider's values first. The values in the video (127.0.0.1, port 1025, no encryption)
# only work with a local test inbox like Mailpit.
set -e
cd /var/www/magento
m() { sudo -u magento bin/magento "$@"; }
m config:set smtp/general/enabled 1
m config:set smtp/general/log_email 1
m config:set smtp/configuration_option/host smtp.example.com
m config:set smtp/configuration_option/port 587
m config:set smtp/configuration_option/protocol tls
m config:set smtp/configuration_option/authentication login
m config:set smtp/configuration_option/username store@example.com
# the password is stored encrypted; read it from the prompt so it stays out of your shell history
read -rsp "SMTP password: " PW; echo
m config:set smtp/configuration_option/password "$PW"
m cache:flush
A real store email
Create a customer account on the storefront. Magento sends the welcome email from the Customer Support sender (set in Lesson 4 under Store Email Addresses), now through SMTP. In the video it arrives in Mailpit from MageBooster Support.
The Email Log
Stores › SMTP › Email Logs lists every email the store sends: subject, sender, recipient, status and time. A failed email has the status Error; from Select you can View it or Resend it. Test emails from Test Now are not logged.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
| Test Now does nothing | The admin is missing the extension’s JavaScript (a 404 for mageplaza/testemail.js). Delete pub/static/adminhtml, pub/static/frontend and var/view_preprocessed/*, deploy the static files again, then flush the cache. |
setup:di:compile fails with “generated/code/… cannot be deleted” | Magento cron ran at the same time. Turn the cron off during the install, run the compile again, then turn the cron back on. |
| “Connection timed out” on Test Now | The host or port is wrong, or the server’s firewall or hosting provider blocks outgoing SMTP. Many hosts block port 25: use 587 or 465. |
| Authentication failed | Check the username and password; with Gmail or Microsoft 365 you often need an app password or OAuth2. |
| Emails arrive in spam | Set up SPF, DKIM and DMARC for your domain at your mail provider, and send from an address on that domain. |
| Save Config is grey | The free extension is not registered: register it under Module Information, or use bin/magento config:set. |
See what is set:
cd /var/www/magento # what is set for SMTP (the password shows encrypted) sudo -u magento bin/magento config:show | grep ^smtp/ # is the module enabled? sudo -u magento bin/magento module:status Mageplaza_Smtp
Next lesson
Lesson 7: the store emails and their templates: order, invoice, shipment, credit memo, welcome and newsletter, and a branded email template.
▶ Watch every MageBooster lesson on YouTube: all lessons in order · subscribe to the channel

