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  “devopsarticle.com” you can set your server name accordingly.

$sudo hostnamectl set-hostname devopsarticle.com

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.

Install-postfix-packages

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

Select-system-name

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 127.0.0.0 (loopback interface) for local only or you can set it according to your requirements

#vi /etc/postfix/main.cf
inet_interfaces = loopback-only

Now, also set myhostname to your FQDN server

myhostname=devopsarticle.com

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" support@devopsarticle.com

To load existing data to mail you use below command,

mail -s "Mail Subject" user@example.com < /home/devops/file.txt

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

Conclusion 

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 Devopsarticle.com

 

Reference

Postfix.org

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

Download-and-install-redhat-linux-8-with-5-easy-steps/

Thanks for visiting to Devopsarticle.com

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.