Press "Enter" to skip to content

How to install, configure and test Postfix SMTP Server for RHEL / CentOS

Do you want to install, setup or configure and test Postfix SMTP Server for RHEL / CentOS?

Here’s are the easy step-by-step how to install, setup or configure and test Postfix SMTP Server for RHEL / CentOS:

Step 1: Install Postfix and Mail Transport Agent Switcher

  • If you did not add postfix and system-switch-mail-gnome during the CentOS installation, you can add it now using Package Manager tool.

Step 2:  Switch to Postfix from Sendmail

By default, Sendmail is the active SMTP server. Here’s how to change it.

  • Click System, select Administration, and click Mail Transport Agent Switcher. This will launch the system-switch-mail window.
  • In the system-switch-mail window, select Postfix and click Ok.

Step 3: Configure Postfix

  • Click Applications, select System Tools then click File Browser. This will launch the File Browser window.
  • In the Location field, type in /etc/postfix and press Enter. If you don’t see the Location field, click the notepad button to toggle to text-based location bar.
  • Double click on the file to open it for editing. We need to make it listen to network request, accept mails bound to our domain and use maildir which is a better mailbox format than mbox the default.
  • Restart the postfix service.
    Type the following command:
    # postfix stop && postfix start

Step 4: Test Postfix

1. Click Applications, select Accessories, and click Terminal. This will launch the Terminal window.
2. In the Terminal window, type in the highlighted commands below.

Sample postfix session. Replace johndoe with any valid user account. The dot after the line test is a command that should be typed in.

[[email protected] ~]# telnet localhost smtp
Connected to localhost.localdomain (
Escape character is '^]'.
220 mail.acme.local ESMTP Postfix
ehlo localhost
250-SIZE 10240000
250 DSN
mail from:<johndoe>
250 2.1.0 Ok
rcpt to:<johndoe>
250 2.1.5 Ok
354 End data with <CR><LF>.<CR><LF>
250 2.0.0 Ok: queued as 9729067C17
221 2.0.0 Bye
Connection closed by foreign host.
[[email protected] ~]#


To check if the mail indeed exists

[[email protected] ~]# cd /home/johndoe/Maildir/new
[[email protected] new]# ls
[[email protected] new]# cat 1185669817.Vfd00I18012M795756.mail.acme.local

Don’t worry, you don’t have to type in the whole filename above. Just type in the first few characters say 118 then press Tab to activate automatic completion.

From [email protected]  Thu Feb 22 21:48:28 2007
Return-Path: <[email protected]>
X-Original-To: johndoe
Delivered-To: [email protected]
Received: from localhost.localdomain (localhost.localdomain [])
        by mail.acme.local (Postfix) with SMTP id 9729067C17
        for <johndoe>; Thu, 22 Feb 2007 21:48:26 -0500 (EST)
Message-Id: <[email protected]>
Date: Thu, 22 Feb 2007 21:48:26 -0500 (EST)
From: [email protected]
To: undisclosed-recipients:;


[[email protected] mail]#