Question

How to set up nginx server to allow WP send emails through gmail.com

Posted April 9, 2021 78 views
NginxWordPress

when I use any Gmail account to WP admin mail I’m not received confirmation mail, How to set up an Nginx server to allow WP to send emails through gmail.com

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @melshity,

By default, WordPress uses the PHP mail function to send out email notifications. However, this function doesn’t work as expected due to a number of reasons.

Most WordPress hosting companies restrict usage of this function to prevent abuse and spam.

Spam filters on popular email service providers check incoming emails to monitor if they are sent from authentic mail servers. Default WordPress emails fail this check and sometimes may not even make it to the spam folder.

SMTP (Simple Mail Transfer Protocol) is the industry standard for sending emails. Unlike the PHP mail function, SMTP uses proper authentication, which increases email deliverability.

You can further check this plugin and how to configure it from this WordPress video:

https://www.youtube.com/watch?v=5YiW4mnn4tE

Additionally, you’ll need to allow outgoing ports 465 and 587. You can do it like so :

sudo iptables -A OUTPUT -p tcp --dport 465 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A INPUT -p tcp --sport 465 -m conntrack --ctstate ESTABLISHED -j ACCEPT

and

sudo iptables -A OUTPUT -p tcp --dport 587 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A INPUT -p tcp --sport 587 -m conntrack --ctstate ESTABLISHED -j ACCEPT

Regards,
KFSys