How To Install and Configure Postfix on Ubuntu Server 20.04

Postfix is an open source MTA which routes e-mails to their destination. It is a default MTA for Ubuntu and is available in Ubuntu's main package repository.

Follow these steps to send e-mails with Postfix

Step 1 : Install Postfix and mailutils with the following commands:

Step 2 : Select Internet Site and then click on [Ok]

Step 3 : On the next screen, enter your domain name, for example, mail.example.com, and answer the other questions. You can leave them with default values

Step 4 : After installation completes, we need to modify the Postfix configuration under /etc/postfix/main.cf

Step 5 : Set myhostname to point to your domain name

Step 6 : Ensure mynetworks is set to the local network. This will secure your server from spammers:

Step 7 : Also check mydestination. It should contain your domain name:

Step 8 : Save the configuration file and exit. Next, reload Postfix for the changes to take effect

Step 9 : Test if everything is working as expected. Open a telnet connection to the mail server:

Step 10 : Now, send your first e-mail from this server.

Troubleshooting the mail server

Step 11 : Start with checking the status of Postfix

Step 12 : You can use a tail command to monitor the stream of logs while the service is running

Step 13 : You can check other log files such as

Step 14 : Check respective ports used by Postfix

Step 14 : Check netstat to make sure services are listening

Step 15 : Check for DNS resolution and MX records