How To Install and Configure Postfix on Ubuntu 23.04

Dec 02, 2023

To set up and configure Postfix on Ubuntu 23.04, follow the steps below.

Step 1 : Update

Begin by updating the package repository to ensure you have the latest information about available packages.

sudo apt update

Step 2 : Install Postfix

Install the Postfix mail server.

sudo apt install postfix

- Choose "Internet Site" when prompted during the installation.

- Enter the System mail name during installation.

Step 3 : Configure Postfix

Run the following command to reconfigure Postfix, providing the necessary details:

sudo dpkg-reconfigure postfix

- Choose "Internet Site" for sending and receiving emails over the internet.

- Enter the fully qualified domain name (FQDN) for your server, such as yourdomain.com.

- Specify the email address where system-generated messages should be sent (e.g., cron jobs, alerts).

- Other Destinations to Accept Mail:

$myhostname, example.com, mail.example.com, localhost.example.com, localhost

- Force synchronous updates on the mail queue? (No)

- Local Networks: Keep the default setting

Mailbox Size Limit: Set the mailbox size limit if needed; the default is 0 (unlimited).

- Local Address Extension Character: Keep the default setting (+).

- Internet protocols to use (all)

Step 4 : Verify Postfix

Check the status of the Postfix service to ensure it is running without issues.

sudo systemctl status postfix

Step 5 : Test Postfix

- Install the mailutils package, including utilities for handling email.

sudo apt install mailutils

- Visit a temporary mail service, (such as temp-mail.org).

- Send a test email to the temporary email address using the mail command.

echo "This is a test email" | mail -s "Test Subject" temporary_email@example.com

- Verify that the test email has been received on the temporary mail service.

Step 6 : Check Mail Logs

Check the mail logs to review any relevant information or issues.

sudo less /var/log/mail.log

Congratulations! You have successfully installed and configured Postfix on your Ubuntu 23.04 system, tested its functionality, and verified the email delivery.