How to Configure SMTP Settings in Magento 2

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.


  1. A Mageplaza account
  2. Back up your server to avoid losing any data if the extension installation fails.
  3. Set pre-installation file permissions.
  4. 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

  1. Set up an account with email service providers such as Google Workspace, MailJet, and Postmark.
  2. 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

  1. Download the “SMTP for Magento 2” extension from the Mageplaza website.

    SMTP for Magento 2 by Mageplaza
    SMTP for Magento 2 by Mageplaza

  2. Log in to your Magento server as the file system owner and go to the Magento root directory.
  3. Update the composer.json file by running the following command:
    composer require mageplaza/module-smtp
  4. 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.
    Access Keys in Magento Marketplace
    Copy and paste the Private key and Public key into the terminal

    If there’s no key available, create a new one by clicking on Create a New Access Key.

  5. Verify the installation by using the following command:
    bin/magento module:status

    You should find the SMTP extension in the list of installed extensions.

  6. 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
  7. Clean and flush cache by following this command:
    bin/magento cache:clean
    bin/magento cache:flush
  8. Disable maintenance mode by running this command:
    bin/magento maintenance:disable

Step 3: Configure SMTP Extension for Magento 2

  1. In the Magento admin panel, go to Configuration > Mageplaza > SMTP.

    Mageplaza extension on Configuration page
    Navigate to SMTP on Configuration page

  2. Expand the General Configuration section. Select Yes from the Enable Mageplaza SMTP dropdown to turn on the extension.

    Enable Mageplaza SMTP in General Configuration section
    Select Yes in the Enable Mageplaza SMTP field

  3. Add a value in Clean Email Log Every text field so that the server is not overloaded with data.

    Clean Email Log Every field
    Add a value in the Clean Email Log Every field

  4. Next, expand the SMTP Configuration Options section.

    SMTP Configuration Options section
    Set up SMTP Configuration Options

  5. In the SMTP Provider field, select the appropriate pre-defined SMTP server.
  6. Click Autofill. Host, Port, Authentication, and Protocol fields will be automatically completed by the selected “SMTP Provider.”
  7. Add your Username and Password of the “SMTP Provider” account.
  8. Click the Save Config button on the top right.

Step 4: Set Up Email Address for SMTP

  1. Go to Stores > Configuration > General > Store Email Addresses.

    Store Email Addresses section on Configuration page
    Change the Sender Name and Sender Email under the General Contaction section.

  2. Expand the General Contact section.
  3. Change the Sender Name and Sender Email of your choice.

Step 5: Send Test Email from Magento 2

  1. Expand the Send Test Email section on the same page and select General Contact from the dropdown.

    Send Test Email
    Select General Contact from the dropdown, add an email address in Send To and click Test Now.

  2. Add an email address in the Send To text field and click Test Now.
  3. Click Save Config.

You should receive a test email.

Omar is a Digital Marketer and the founder of StartMarketing. He received his Master's degree from Queen's University, Belfast in 2017 and launched many successful web projects for clients since then. His expertise is in SEO, content management and social media marketing.

Leave a Comment