Before even thinking of installing and configuring Postfix or any email server on your system, it is a good idea to test that your system (being a VPS on a cloud provider or a machine at home) has outbound TCP port 25 (SMTP) connectivity.
An email server needs to connect to TCP port 25 of other email servers to send outbound emails. Similarly other email servers need to connect to TCP port 25 of your server to deliver emails destined to your server.
An easy test is to connect to your Linux system using SSH or any other method that will allow you to access command line interface.
You can then test outbound connectivity to a known email provider like this:
$ host -t mx gmail.com ## Find out host names of their email servers...
gmail.com mail is handled by 10 alt1.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 5 gmail-smtp-in.l.google.com.
gmail.com mail is handled by 30 alt3.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 20 alt2.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 40 alt4.gmail-smtp-in.l.google.com.
Select one server from the list and run:
$ telnet gmail-smtp-in.l.google.com 25
Trying 64.233.166.26...
Connected to gmail-smtp-in.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP f7si810252wro.562 - gsmtp
quit
221 2.0.0 closing connection f7si810252wro.562 - gsmtp
Connection closed by foreign host.
If your system has outbound TCP port 25 connectivity you will get the above output. (Note: You can enter the quit
command as shown above to terminate the telnet
connection.)
If your cloud provider, your ISP, or any type of firewall in between is preventing the outbound TCP port 25 connectivity, you will get an output like the one given below (after waiting a certain amount of time for telnet
to time out):
$ telnet gmail-smtp-in.l.google.com 25
Trying 173.194.216.26...
Trying 2607:f8b0:400c:c06::1b...
telnet: Unable to connect to remote host: Network is unreachable
Most Cloud and Internet Service Providers (ISPs) now block all outgoing TCP port 25 traffic from their customers in a futile attempt to fight spam. So, you need to check with your provider if this is the case and whether your provider is going to lift this block or not. Some providers (like Google Cloud Platform or Amazon Web Services) will not do it. So, you will have no chance to run Postfix on such platforms.
telnet gmail-smtp-in.l.google.com 25
. Outbound SMTP (port 25) is disabled in most cloud providers including AWS, GCP (Google), etc.