Oracle Linux 8.3 template is now available

How to Install and Configure Postfix as a Send-Only SMTP Server on Ubuntu 20.04

Joe Harris
September 4, 2020

Postfix is used for sending and receiving emails. There are often situations when the server only needs to send mail. For example, to send notifications from apps. In such cases, the Postfix option for sending messages only is useful.

Initial conditions

  • Ubuntu 20.04;
  • Domain name;
  • DNS A record, containing the public IP address of your domain;
  • TLS certificate for e-mail encryption;

Step 1 – Installing Postfix

The easiest way is to install mailutils package, which contains Postfix and some other packages.

sudo apt install mailutils
During installation, a window for configuring Postfix will appear.

Postfix mail server configuration
Screenshot 1. Postfix Configuration.

An Internet site is the most suitable option in our case. After selecting it, set the System mail name. It must be equal to the hostname and your domain name.

Postfix System mail name configuration
Screenshot 2. Postfix System mail name configuration.

Step 2 - Configuring Postfix

To send emails only from the current server, we only need to listen to the loopback interface. Therefore, in the file change the “inet_interfaces” parameter to loopback-only.

sudo nano /etc/postfix/
inet_interfaces = loopback-only

Also adjust the mydestination parameter as follows.

mydestination = localhost.$mydomain, localhost, $myhostname

Restart Postfix.

sudo systemctl restart postfix

The current settings are sufficient for sending emails from the server. Let's test it.

Step 3 – Postfix testing

We will use the mail command to check whether Postfix will send an email.

echo "Fill in some text of the email here" | mail -s "Message subject" recipient's-email-address

Fill in the message text and title. The email will be sent to the specified address instead of the recipient's-email-address.

If the email doesn't arrive, check the Spam folder. If it is not there, then you need to check the configuration. Another cause of problems may be a mismatch between the host name, server name, and your domain name.

Step 4 - Enabling SMTP encryption

Email encryption is very important for security reasons. In addition, some servers consider unencrypted emails to be spam.
To encrypt email, you must specify a valid certificate in the Postfix configuration.

sudo nano /etc/postfix/

Specify the path to the TLS domain certificate in the smtpd_tls_cert_file field, the private key in the smtpd_tls_key_file, and enter yes in the smtp_use_tls.

# TLS parameters

Restart Posfix.

sudo systemctl restart postfix

Step 5 - Setting up aliases

Sometimes you need to redirect internal messages for users to the mailbox. For example, to redirect system messages. Aliases are used for this purpose. To configure them, edit the file:

sudo nano /etc/aliases

Add a line to the end of the file. In this example, we will configure sending system messages to


Save the file and close it. To apply the changes, enter the command:

sudo newaliases

Start your cloud journey. Take the first step right now.
We use cookies to provide our services and for analytics and marketing. To find out more about our use of cookies, please see our Privacy Policy. By continuing to browse our website, you agree to our use of cookies.