24.06.2025

Install and Configure Postfix as a Send-Only SMTP Server on CentOS 8

Configuring a mail server to send outgoing messages only is a common and practical approach when administering Linux servers. This setup is especially useful for system alerts, Cron job notifications, automated scripts, and monitoring tools that need to send email reports or warnings, but do not require the ability to receive mail. In this tutorial, we’ll walk you through installing and configuring Postfix as a send-only SMTP server on CentOS 8 — a lightweight, secure, and reliable way to send emails directly from your server.

Before you begin, make sure you have the following prerequisites:

Installing and configuring Postfix

Let's install the required packages. Postfix is the mail server itself, and mailx is the environment for handling email.

dnf install -y postfix mailx

Activate the start together with the system and run Postfix.

systemctl enable --now postfix

Open the Postfix configuration file.

nano /etc/postfix/main.cf

You need to find the inet_interfaces parameter and assign it the localhost value if it is different at the moment. In my case, the parameter was listed several times, but with the correct value.

inet_interfaces = localhost

Set the myhostname parameter to your domain name.

myhostname = domain-name.com

Uncomment this line:

myorigin = $myhostname

Make the line look like this and replace the domain name with your own:

mydestination = $myhostname, domain-name.com, localhost.$mydomain, localhost

Save and close the file and restart the system.

reboot

Now you need to configure the hostname for the server.

hostname domain-name.com
echo "domain-name.com" > /etc/hostname

These settings are sufficient in many cases, but some mail servers have fairly strict spam filters and will reject mail. In this case, additional steps are required. One of which is setting up a PTR record for a domain. Usually, to do it, you need to contact the support service of the company that provided you with a public IP address.

Postfix testing

To send a test message, use the command:

echo "Mail delivery test" | mail -s "[Server] New e-mail" mail@domain.com

The mail address must be replaced with a real one, and the text in quotation marks represents the body of the letter and its header.

Configuring mail forwarding

Sometimes you need to receive the host's internal mail to an external mailbox. For example, to receive system notifications. There are aliases for these purposes. Let's take a look at setting up mail forwarding for root. Open the file with aliases.

nano /etc/aliases

To add mail forwarding for root to an external mailbox, add a line with your mailbox:

root: mail@domain.com

Save the file and enter the command to apply the changes:

newaliases

Conclusion

Setting up Postfix as a send-only SMTP server on CentOS 8 is a simple yet powerful way to enable your server to send system-generated emails, such as alerts, cron job reports, and service notifications. This configuration reduces your server’s exposure to incoming email threats, while ensuring reliable email delivery for administrative purposes. By following this guide, you’ve learned how to install Postfix, configure it to send messages only, and prepare your server to handle outbound emails effectively. For best results, don’t forget to set up proper DNS records such as SPF, DKIM, and DMARC to improve deliverability and prevent your messages from being marked as spam.

FAQ: Postfix Send-Only SMTP on CentOS 8