Postfix: setting up a Send-Only SMTP Server

Hello Friends, in this article I am going over on how to set up a send-only SMTP Server with Postfix on Ubuntu Server 20.04. In most scenarios servers only need to be able to send out emails and not receive emails for example a server can be set up to email log files or triggered events on a server for example if someone logged in or when a system change occurred.

Postfix Send-Only SMTP
Postfix Send-Only SMTP

Postfix installation

As usual it is expected that you already have a running Ubuntu Server but if you need help with that please read here. Let’s start by updating the repositories and install missing updates.

sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -y

It is vital for an email server to have a proper name so that the from address will show from where it came from. Use the following command to set the full host-name. Replace “servername.domain.com” with an actual host-name for example: logserver.cyberhelp.us

sudo hostnamectl set-hostname servername.domain.com

Your servers full host-name should match its public DNS A-Record. That is very important. Now that this is done lets install postfix and mailutils

sudo apt install postfix mailutils

After you issued that command you should see something like the following below.

Postfix install

Hit the letter “y” to confirm and the installation procedure continues and you should be seeing the following:

Postfix configuration

Select “Internet Site” if you server is facing the internet otherwise select the next best scenario fitting your situation. Hit enter and you should see the following screen:

Postfix Hostname verification

Make sure that the installation wizard caught the servers name properly, if not make the necessary adjustment. When everything is correct hit enter to finish the installation.

Postfix configuration

Perfect the Postfix Server is now installed. Let’s go ahead and configure it so it will only send out emails and not receive any. In order to tell Postfix how to work the main.cf file needs to be edited. The file is located at /etc/postfix/main.cf. Basically there are two lines that require adjustment. Open up the file and look for the options: inet_interface & myhostname.

inet_interface = loopback-only

and then check that the server name is set properly:

myhostname = logserver.cyberhelp.us

When you are done making those adjustments it should something like the following:

Postfix main.cf config file

The configuration is done one last step is left. Restating Postfix in order to apply the changes. Execute the following command:

sudo systemctl restart postfix

The Postfix Send-Only mail server has been setup and lets test is very quick but sending an email out and check our mailbox to see if it arrived.

The mailutils package that we installed earlier provides us with a command line mail client. Run the following command to write and send an email.

echo “Testing Postfix Send-Only email Server” | mail -s “Postfix email server test” user@domain.com

Replace user@domain.com with the email address you like to receive the test email on. Go to your mailbox and see if you received the email from this server.

Conclusion

As you have seen it is fairly easy and quick to install a send-only email server with Postfix on Ubuntu Server 20.04 LTS. If you like to read more about Postfix click on this link. I hope you like this article and I would appreciate if you leave a comment and perhaps share this article with other. Thank you 😉