This question already has an answer here:

I really need your help. I am trying to set up first time my own mail server using Postfix, Dovecot IMAP/POP3 and MySQL backend on a Ubuntu server. I can successfully receive and send mail to my local server, However I can only send mail to to other mail servers like gmail and outlook but unable to receive. and always get this

The recipient server did not accept our requests to connect. Learn more at https://support.google.com/mail/answer/7720 [xyz.example.com. xxx.xxx.xxx.xxx: timed out]

my domain is something like xyz.example.com not www not mail.example.com

I have used dig MX xyz.example.com which produce

xyz.example.com.     60      IN      MX      60 xyz.example.com.

However when I try mxtoolbox.com to test smtp

SMTP Connect Failed To Connect More Info

Session Transcript:

Connecting to xxx.xxx.xxx.xxx

Connection attempt #1 - Unable to connect after 15 seconds. [15.05 sec]

I have also tried

telnet xyz.example.com 25

along with 465, 587, 993, 995

Trying 123.345.567.789.
Connected to xyz.example.com.
Escape character is '^]'.
220 xyz.example.com ESMTP Postfix (Ubuntu)

When I tried telnet externally

couldn't open connection to the host, on port 25: connect failed"

My domain is certified but I am using openssl certificate for encryption. I don't know what I am doing wrong, please guide me and help me out. Thanks in advance

marked as duplicate by Jenny D, Ward, peterh, quadruplebucky, MadHatter Jun 14 '17 at 20:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You mentioning that telnet works on port 25 (forget all other ports for now). Are you trying to telnet from your lan or externally? I would suggest to try from another lan or internet data connection from your phone carrier. The MXtoolbox says it cannot connect so it sounds pretty much like firewall/router or wrong MX pointing. – Alexios Pappas Jun 5 '17 at 2:27
  • I have tried telnet from pc using cmd, it says,"couldn't open connection to the host, on port 25: connect failed". – sonubreeze Jun 5 '17 at 3:56
  • can you please tell me what I need to do to fix this ? – sonubreeze Jun 5 '17 at 4:15
  • If the telnet is working internally and not externally you should check your router/firewall configuration. If it doesn't work internally either (from what you mentioned on your first post internally works) you should check the server firewall iptables etc. – Alexios Pappas Jun 5 '17 at 17:11
  • Show us your master.cf. Should have something like smtp inet n - n - - smtpd. – Chloe Jun 5 '17 at 17:45

It sounds like the piece you missed is the port forward, or NAT translation to allow the internet to get to your mail server on port 25. You need to allow the remote servers to contact your public IP, and have that information allowed through your firewall to the mail server.

More specific help with this may be available if you add information about your network (e.g firewall, router, etc.).

I would also like to add that if this is your first time setting up a mail server, you NEED to make sure you look up how to NOT be an open relay. If you open up your mail server without the proper protections in place, it will be days (or maybe hours...) before your server is helping send out LOTS of spam. But don't worry, that won't go on too long before you end up on various block lists across the web. All of this is easily avoidable if you put a couple simple protections in place. </PublicServiceAccouncement>


Troubleshooting Problems with Postfix, Dovecot, and MySQL

This is an excellent guide to troubleshoot Postfix and Dovecot problems, I have followed it's instruction to find out what is the problem. Anyone who is trying to set up mail server for the first time like me must follow this guide to know how to debug problems with Postfix, Dovecot, and MySQL.

In my case,

when I tried telnet on server,it succeeded. But when I tried externally from my home computer it failed.

That indicates that the outgoing ports were being blocked by my hosting provider. I asked them to open it up. When they did, I suddenly started receiving emails.

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