Custom SMTP for Magento2
Online Documentation

Leave the setup & debugging to us,
so that you can focus your time on what you do best.

Purchase Support

Related Extensions

Get more from your Magento2 store!

Enhanced Transactional Emails

Enhanced Transactional Emails

Get more from your order confirmation emails by promoting other complementary products.

Enhanced Success Page

Enhanced Success Page

Add cross-sell, upsell, related products, social media links and other elements to your order confirmation.

Order Shipment Tracking

Order Shipment Tracking

Providing your customer with a beautiful and functional order package tracking without leaving your site.

SMTP Configurations

Reduce sending emails to your customers' junk mail folder with our SMTP extension!

Gmail / Google Business

Configurations

Office 365 / Outlook

Configurations

AWS / Amazon SES

Configurations

Total Downloads Latest Stable Version GitHub stars GitHub forks

Configuring SMTP Magento

What is SMTP for Magento?

Simple Mail Transfer Protocol (SMTP) allows your Magento 2 store to send email through a specific third-party mail SMTP server. You can configure your Magento store to use your Gmail, Amazon, Microsoft or any other mail server account to send all your emails. All you need is to configure the mail server settings in our Magento extension.

Extension Support

Like all other open source projects, sometimes things work and sometimes they don't for one reason or another.

We receive multiple emails & support tickets almost daily asking for help and we would love to help but in most cases, these issues have nothing to do with our extension and mostly caused by lack of basic Magento knowledge.

At MagePal our main focus is designing great Magento Extension and due to our limited resources, we simply can not provide free support for a free product.

Our affordable technical support include help with installation, usage, configuration, and troubleshooting for our Free Community Edition extensions.

Installation Guide

Step 1

composer require magepal/magento2-gmailsmtpapp

Step 2 - Enable Custom SMTP (“cd” to {Magento root} folder)

  php -f bin/magento module:enable --clear-static-content MagePal_GmailSmtpApp
  php -f bin/magento setup:upgrade

Google Tag Manager

Step 3 - How to Configure Magento SMTP

Log into your Magento 2 Admin

  1. Goto Stores
  2. Configuration
  3. MagePal
  4. SMTP Configuration
  5. Configure your SMTP setting

SMTP Configuration Settings

Supported SMTP Providers

Integrate Magento 2 with virtually any SMTP provider, quickly and easily!

How to update to the latest version

Step 1

composer update magepal/magento2-gmailsmtpapp

Step 2 - Enable Custom SMTP (“cd” to {Magento root} folder)

  php -f bin/magento setup:upgrade

SMTP Debugging & Troubleshooting - Magento

Regardless of the problem you’re having, first check to sure you are using the latest version of our SMTP extension. When debug SMTP issues they are several point of failure and understanding the error message is key to quickly figure out your issue.

Common point of failure

Web Server Configuration Test

SMTP uses PHP mail, so the first thing you need to test is if php Mail is installed. Log into your server by ssh and run the command below.

Test if php mail is installed
php -r "mail('me@myEmail.com', 'Is PHP Mail Setup', 'Yes - I got this email');"
Expected Result

Blank line, no error

Possible Error Messages
sh: 1: /usr/sbin/sendmail: not found
Test if port is open
telnet smtp.gmail.com 465
Expected Result
Trying 173.194.204.109...
Connected to gmail-smtp-msa.l.google.com.
Connection refused

Connection refused normally means that something is blocked, so you should check with your hosting company or documentation to see if there is any special instruction to sending email in their infrastructure. E.g. GoDaddy blocks outbound SMTP, to all Host once it is not one of GoDaddy’s servers.

Possible Error Messages
Trying 173.194.192.109...
telnet: connect to address 173.194.192.109: Connection timed out

DNS Failures

These are often seen as connection timeouts, or “Temporary failure in name resolution”, “could not resolve host”, “getaddrinfo failed” or similar errors.

dig +short smtp.gmail.com
Expected Result
gmail-smtp-msa.l.google.com.
173.194.67.108

If this fails, our SMTP extension or not other SMTP extension will be able to send email because it won’t be able to obtain the correct IP address to connect to. You could try to use the direct IP address of the hostname you are trying to connect to. To fix this you need to figure out why your DNS is not resolving.

If dig is not configure on your server you could try

ping smtp.gmail.com
Firewall redirection

Another thing to make sure that the name the mail server responds with should be related to the server you requested, as you can see in the above example - we use telnet to connect to smtp.gmail.com and got gmail-smtp-msa.l.google.com, which is redirecting internally by google - but this could as easily be done by either your hosting provider or ISP which is often the case for port 25. This would mean that your your ISP’s or hosting provider firewall is redirecting you transparently to their own mail servers, and you’re likely to see authentication and TLS certificate verification failures issues.

SELinux blocking

If you are getting error message like SMTP -> ERROR: Failed to connect to server: Permission denied (13), Permission denied, and your are hosting on RedHat / Fedora / Centos this is more than likely cause by SELinux preventing PHP or the web server from sending email. . Using the getsebool command we can check if the httpd daemon is allowed to make a connection over the network and send an email:

getsebool httpd_can_sendmail
getsebool httpd_can_network_connect

This command will return a boolean on or off. If it’s off, we can turn it on:

sudo setsebool -P httpd_can_sendmail 1
sudo setsebool -P httpd_can_network_connect 1

If you’re running PHP-FPM via fastcgi, you may need to apply this to the fpm daemon rather than httpd.

Authentication failures

There are several likely causes, if your authentication is failing:

Gmail, OAuth2 and “Allow less secure apps”

As of December 2014, in order to better secure customer’s email account Google has implemented new authentication mechanism called XOAUTH2 based on OAuth2 specification for access to their various services, including Gmail. This change can break both SMTP and IMAP access to Gmail or G-suite, and you may receive various authentication failures (“5.7.14 Please log in via your web browser and then try again” or “Username and Password not accepted”) while testing your configuration from our extension. Included in the error message is a link to https://support.google.com/mail/bin/answer.py?answer=78754, which provide a list of possible causes, or https://support.google.com/mail/?p=BadCredentials, which for the most part does not provide enough information. Currently our smtp extension does not support OAuth2 which would take a lot more time to setup.

“Could not instantiate mail function”

This error normally means that your PHP installation is not configured to send mail using the mail() function correctly. The most likely cause is this issue are sendmail_path is not set correctly in your php.ini or there is not local mail server installed and configured to send mail. (see Test if php mail is installed)

Self-signed SSL certificates

Currently our extension does not support Self-signed SSL certificates or other less know type of certificate. It normally cheaper to purchase a valid ssl vs the amount of work that will be require to make some certification work with SMTP. Possible solution see https://github.com/magepal/magento2-gmail-smtp-app/issues/30#issuecomment-262467780

If your are still having SMTP issues…

If all or any of the above setting or server is not correctly configured, our SMTP extension or any other SMTP extension will not send emails with Magento2, and usually there’s nothing our extension can do about it and you only solution is first fix your network, then try again.

If you are using a third party manage hosting provide and do not have control of your own firewall or DNS, you more than likely need to create a support ticket with your ISP to change your server configuration and to fix this issue (it’s very common for them to block or divert port 25 outbound and other ports by default). If they won’t fix it or can not figure it out then you may need to change your ISP.