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.
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.
Need Help? Purchase Support
composer require magepal/magento2-gmailsmtpapp
php -f bin/magento module:enable --clear-static-content MagePal_GmailSmtpApp php -f bin/magento setup:upgrade
Log into your Magento 2 Admin
Like our extensions? Please take a minute to do quick Google Review.
Please Note : Reviewing our extensions, not only help us improve our plugins but also let others know how much we care about creating the best Magento 2 extensions.
Integrate Magento 2 with virtually any SMTP provider, quickly and easily!
composer update magepal/magento2-gmailsmtpapp
php -f bin/magento setup:upgrade
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
Authentication required (repo.magento.com) Username:
You will need to log into Magento Marketplace to get your authentication keys
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.
php -r "mail('me@myEmail.com', 'Is PHP Mail Setup', 'Yes - I got this email');"
Blank line, no error
sh: 1: /usr/sbin/sendmail: not found
telnet smtp.gmail.com 465
Trying 220.127.116.11... Connected to gmail-smtp-msa.l.google.com.
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.
Trying 18.104.22.168... telnet: connect to address 22.214.171.124: Connection timed out
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
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.
dig is not configure on your server you could try
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.
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.
There are several likely causes, if your authentication is failing:
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.
For security reasons Gmail does not like unexpected or unfamiliar clients connecting to gmail accounts, so you may require to log into your gmail account from a browser as mentioned in error output, or to visit the CAPTCHA page mentioned in their support doc.
Enabling “Allow less secure apps” will usually solve the problem for our extension, since our recommendation is to use a dedicated email address to send mail it will not make your app significantly less secure. Please note that sometime changing this setting may take an hour or more to take effect.
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)
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 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.