Thursday, October 16, 2025
HomeGuest BlogsInstall and Configure Postfix on Ubuntu 22.04|20.04|18.04

Install and Configure Postfix on Ubuntu 22.04|20.04|18.04

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

In this guide we’ll look at how you can configure Postfix MTA as a send-only SMTP server on Ubuntu 22.04|20.04|18.04 LTS, meaning it doesn’t receive and process emails. Its job is only to act as Local mail transfer agent. Postfix is a popular open source Mail Transfer Agent (MTA) used in Linux and Unix environments.

A send only mail server is useful especially when used in scripting, e.g having a cron job that sends an email about the status of its execution, or an application that sends an email to you when certain events happen.

Configure Postfix as a Send-Only SMTP Server on Ubuntu

Installing and configuring Postfix as a Send-Only SMTP Server on Ubuntu is an easy process. Start by updating your system:

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}
sudo apt update

Also set a hostname for the server so that emails will show a from address with valid domain section.

sudo hostnamectl set-hostname server1.example.com

Download mailutils which install postfix and other mail utils for you:

sudo apt install mailutils

As the package installs, you’ll be asked to select an option on screen for your mail server. For ” General type of email configuration” window, select Internet site and click OK button

set postfix internet site min

The next page will ask you to set your Mail server name, this can be domain or server hostname with an A record.

set mail server name min

Select OK to save the settings and finish the installation.

Configure Postfix MTA Server

Edit Postfix configuration file /etc/postfix/main.cf to ensure it is configured as send only ( Only relaying emails from the local server).

Set Postfix to listen on the 127.0.0.1loopback interface. The default setting is to listen on all interfaces.

inet_interfaces = loopback-only

Also, set myhostname to your Server FQDN

myhostname=myserver.example.com

See screenshot below

postfix set listen address and myhostname min

Restart Postfix service for it to pick the new changes:

sudo systemctl restart postfix

You have successfully installed and configured Postfix as a Send only MTA server. To test email delivery, use the mail command like below

echo "Postfix Send-Only Server" | mail -s "Postfix Testing" [email protected]

You can also load existing data to mail

mail -s "Mail Subject" [email protected] < /home/jmutai/file.txt

This will send an email with the content loaded from /home/jmutai/file.txt
in the message section.

We have other Postfix related articles on our blog:

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS