News
3 new Serverspace GPT API Language Models available now!
JH
Joe Harris
February 27 2021
Updated June 24 2025

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

CentOS Linux SMTP

Using another OS?

Select the desired version or distribution.

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.

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

  • 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.
Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.