Why postfix on Ubuntu 20.04 does not send email to external email accounts?

I followed the article (“How To Install and Configure Postfix as a Send-Only SMTP Server” from Digital Ocean knowledge base) line by line several times and the most I got was to send email within internal users. I can’t get postfix sending email to external email accounts, hence my Magento installation won’t send out email do my customer. Any clue what could it be?

Thank you,


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @helenapreclikova,

Most probably your sending port, either 25, 465 or 587 is not allowed to do outgoing connections. If you are using UFW please do the following:

sudo ufw allow 25/tcp
sudo ufw allow 465/tcp
sudo ufw allow 587/tcp
sudo ufw reload

If you are using plain IPtables use:

iptables -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --dport 465 -j ACCEPT
iptables -A INPUT -p tcp --dport 587 -j ACCEPT

Now to allow access to incoming connections:

Allow All Incoming SMTP To allow your server to respond to SMTP connections, port 25, run these commands:

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

The second command, which allows the outgoing traffic of established SMTP connections, is only necessary if the OUTPUT policy is not set to ACCEPT.

Regards, KDSys