0

In Magento 2, How to config mail sending ? I used the gmail host to test. I set below but I try use feature forgot password on front-end and then I can't see email in client's mail box. enter image description here

View "forgot password" enter image description here

  • 1
    To send email using Gmail SMTP server you need to either (1) reconfigure your server to send email through Gmail or (2) install a third-party extension. eg github.com/magepal/magento2-gmail-smtp-app – Renon Stewart Feb 23 '18 at 22:11
  • 1
    magepal smtp extension works great! – LucScu Apr 6 '18 at 10:50
3

Mailing in Magento 2 isn't sended by smtp by default, it uses mail PHP function. To use smtp you have to install extension, ie. Extension1 (paid) or Extension2 (free)

You can also write your own module to do so (like in this tutorial) :)

2

Without adding an extention, the best way is to add and configure PostFix for Gmail account (Tested on Mac & Linux):

SASL Authentication

Connecting to the Gmail SMTP server requires both SSL and authentication. To set up authentication you will need to edit the /etc/postfix/sasl_passwd file.

sudo vim /etc/postfix/sasl_passwd

Update the contents to include the following. Note that enclosing hostnames with square brackets – [] – tells Postfix to avoid doing an MX lookup. Make sure to replace EMAIL with your email address, and PASSWORD with your Gmail password, properly escaping any colons in it.

[smtp.gmail.com]:587 EMAIL@gmail.com:PASSWORD

Use the postmap command to update the SASL credentials in Postfix :

sudo postmap /etc/postfix/sasl_passwd

Postfix Relay Configuration

Next we need to edit the Postfix configuration found in /etc/postfix/main.cf.

sudo vim /etc/postfix/main.cf

I was not able to route mail to the Gmail SMTP servers over IPv6, so force only IPv4 connections by searching for the inet_protocols key and updating the value.

inet_protocols = ipv4

If any of the following keys already exist in your configuration comment them out, and include the following at the bottom of the config file.

Gmail SMTP relay

relayhost = [smtp.gmail.com]:587

# Enable SASL authentication in the Postfix SMTP client.
smtpd_sasl_auth_enable = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtp_sasl_mechanism_filter = AUTH LOGIN

# Enable Transport Layer Security (TLS), i.e. SSL.
smtp_use_tls = yes
smtp_tls_security_level = encrypt
tls_random_source = dev:/dev/urandom

Restart Postfix & Test

Restart Postfix as root, then send a test email.

sudo postfix stop && sudo postfix start
date | mail -s "Test Email" YOUR_EMAIL@gmail.com
  • I have the exact same config but when i send magento order email it says mailq is empty. the mail function sends email but magento does not use postfix – Reena Parekh Aug 24 at 9:47
1

Magento 2 send via PHP Email by default. If you want to use Gmail to send email, you should try to install Custom SMTP module. I found this SMTP module on Github - Yes, Free :)

Hmm, a screenshot:

smtp configuration

User guide: https://github.com/mageplaza/magento-2-smtp#user-guide

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.