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:
- A registered domain name that will be used in the "From" address of outgoing emails (e.g., noreply@yourdomain.com)
- Root access to the CentOS 8 server or a user with sudo privileges
Installing and configuring Postfix
Let's install the required packages. Postfix is the mail server itself, and mailx is the environment for handling email.
Activate the start together with the system and run Postfix.
Open the Postfix configuration file.
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.
Set the myhostname parameter to your domain name.
Uncomment this line:
Make the line look like this and replace the domain name with your own:
Save and close the file and restart the system.
Now you need to configure the hostname for the server.
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:
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.
To add mail forwarding for root to an external mailbox, add a line with your mailbox:
Save the file and enter the command to apply the changes:
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
- Q: Can I use Postfix to receive emails as well?
A: This guide covers send-only configuration. If you need to receive emails, additional setup (e.g., Dovecot or another POP/IMAP service) is required. - Q: Why use a send-only SMTP server?
A: A send-only SMTP server is ideal for servers that only need to send system alerts, cron job results, or monitoring notifications, without accepting incoming mail — improving security and simplicity. - Q: Do I need a domain name to send mail with Postfix?
A: Yes, a valid domain name is recommended to ensure that your emails have a proper sender address (e.g., noreply@yourdomain.com) and aren’t flagged as spam. - Q: Will my emails be marked as spam?
A: To avoid this, configure proper SPF, DKIM, and DMARC DNS records and use a valid domain. Some email providers may still apply strict filtering if these settings are missing. - Q: Can I use an external SMTP relay with Postfix on CentOS 8?
A: Yes, Postfix can be configured to relay email through providers like Gmail, Amazon SES, or SendGrid. This is useful if your server has issues with email deliverability.