How To Install and Configure Postfix on Ubuntu 22.04

Postfix is a popular mail transfer agent (MTA) that is used to send and receive emails on a Unix or Linux system. Here's a step-by-step guide on how to install and configure Postfix on Ubuntu 22.04:

Step 1 : Update Package Repository Information

Step 2 : Install Postfix

During the installation, you will be prompted to select the mail server configuration. Choose "Internet Site" and press Enter. Enter your fully qualified domain name (FQDN) when prompted.

Step 3 : Configure Postfix

Once installed, you can reconfigure Postfix:

General mail configuration type: Internet Site

System mail name: example.com (not mail.example.com)

Recipient for root and postmaster mail: The username of your primary Linux account (sammy in our examples)

Other destinations to accept mail for (blank for none): $myhostname, example.com, mail.example.com, localhost.example.com, localhost

Force synchronous updates on mail queue?: No

Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

Mailbox size limit (bytes) : 0

Local address extension character: +

Internet protocols to use: all

Step 4 : Verify Postfix Configuration

To check if Postfix is running and configured correctly, you can use the following commands:

This command will show the status of the Postfix service.

Step 5 : Basic Configuration (Optional)

If you need to make additional changes to the configuration, you can edit the main configuration file:

Step 6 : Restart Postfix

After making changes to the configuration, restart the Postfix service:

Step 7 : Test Postfix

Install mailutils

Open the temporary email service website, such as https://temp-mail.org/en/, and note down the temporary email address generated for you.

To test if your Postfix setup is working, you can send a test email using the mail command:

Replace your_email@example.com with the actual email address where you want to receive the test email.

Step 8 : Check Mail Logs

You can check the mail logs to troubleshoot any issues:

This will display the latest entries in the mail log.

Congratulations! You have successfully installed and configured Postfix on Ubuntu 22.04.