Install & configure Postfix SMTP only server on Ubuntu 18.04 & 20.04

In this article you will learn how to install, configure “Posfix SMTP only Server” with easy steps on Ubuntu 18.04 & 20.04 Postfix is a popular open source Mail Transfer Agent. Its used in Linux and Unix environments

Send mail SMTP only server useful in case of you want to get activities mail from servers. Once you configured this Posfix smtp only server, it will send you mails on any particulate events occurred.

Step.1 Update server

Use below  command to get up to date your server.

$sudo apt update

Step.2 Set server name

Its important to set proper name for your server to identify domain and from mail details. Use below command, in my case I am using  “” you can set your server name accordingly.

$sudo hostnamectl set-hostname

Step.3 Install packages

Use below command to install packages,

$sudo apt install mailutils

While installing packages, you will get below screen. Select the option “Internet Site” and click on OK under General Type of mail configuration.


Next it will asked you to set you mail server name, this can be your domain or server hostname with an A record.


Now, finish the installation by following the next procedures.

Step.4 Configure Postfix

We have to add information in main config file to ensure settings for send mail only. By default setting is to listen on all interfaces, you have to set it to (loopback interface) for local only or you can set it according to your requirements

#vi /etc/postfix/
inet_interfaces = loopback-only

Now, also set myhostname to your FQDN server

Step.5 Restart Postfix service

Use below commands to restart postfix service,

$sudo systemctl restart postfix

Now you have installed and configured Postfix as a send only mail server. To test it use below mail command,

echo "Postfix Send-Only Server" | mail -s "Postfix Testing"

To load existing data to mail you use below command,

mail -s "Mail Subject" < /home/devops/file.txt

It will send mail with content from /home/devops/file.txt in message section.


This way we have learnt how to install, configure Posfix smtp only server with easy steps on Ubuntu 18.04 & 20.04

Hope this article helpful for you, please like, share and subscribe to



Related Article

Install,create,backup & restore MySQL on Ubuntu 20.04 LTS 6 easy steps

What is LAMP stack? How to install LAMP server on Centos7, Red Hat and Fedora with 12 easy steps


Thanks for visiting to

Suresh Dike

Suresh Dike I am Suresh, working on Cloud, DevOps, Linux, Firewalls,Docker and Kubernetes. Believes in sharing the knowledge.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.