Since Magento doesn’t provide a solution to configure SMTP in Magento 2, you need extensions like SMTP Configurator by Webkul or Magento 2 SMTP by Mageplaza.
The advantage of using the Magento 2 SMTP extension is that it’s free and supports all popular email service providers like Gmail, Mailgun, and Office 365.
This article shows you how to configure SMTP settings in Magento 2 by using the Magento 2 SMTP by Mageplaza. We show you how to install the extension and set it up on the Magento backend.
Prerequisites
- A Mageplaza account
- Back up your server to avoid losing any data if the extension installation fails.
- Set pre-installation file permissions.
- Enable developer mode using the following command:
php bin/magento deploy:mode:set developer
Installing Magento 2 SMTP
Step 1: Create an Account with an Email Service Provider
- Set up an account with email service providers such as Google Workspace, MailJet, and Postmark.
- Note the SMTP credential of the email service provider to add the details to the SMTP extension.
Step 2: Download and Install Magento 2 SMTP Extension
- Download the “SMTP for Magento 2” extension from the Mageplaza website.
- Log in to your Magento server as the file system owner and go to the Magento root directory.
- Update the composer.json file by running the following command:
composer require mageplaza/module-smtp
- If prompted to enter authentication keys, go to Magento Marketplace > My Products > Access Keys. Use Public Key as your username and Private Key as your password.
If there’s no key available, create a new one by clicking on Create a New Access Key.
- Verify the installation by using the following command:
bin/magento module:status
You should find the SMTP extension in the list of installed extensions.
- Run the following command to register the extension, recompile code, and redeploy static view files:
bin/magento setup:upgrade bin/magento setup:di:compile bin/magento setup:static-content:deploy
- Clean and flush cache by following this command:
bin/magento cache:clean bin/magento cache:flush
- Disable maintenance mode by running this command:
bin/magento maintenance:disable
Step 3: Configure SMTP Extension for Magento 2
- In the Magento admin panel, go to Configuration > Mageplaza > SMTP.
- Expand the General Configuration section. Select Yes from the Enable Mageplaza SMTP dropdown to turn on the extension.
- Add a value in Clean Email Log Every text field so that the server is not overloaded with data.
- Next, expand the SMTP Configuration Options section.
- In the SMTP Provider field, select the appropriate pre-defined SMTP server.
- Click Autofill. Host, Port, Authentication, and Protocol fields will be automatically completed by the selected “SMTP Provider.”
- Add your Username and Password of the “SMTP Provider” account.
- Click the Save Config button on the top right.
Step 4: Set Up Email Address for SMTP
- Go to Stores > Configuration > General > Store Email Addresses.
- Expand the General Contact section.
- Change the Sender Name and Sender Email of your choice.
Step 5: Send Test Email from Magento 2
- Expand the Send Test Email section on the same page and select General Contact from the dropdown.
- Add an email address in the Send To text field and click Test Now.
- Click Save Config.
You should receive a test email.