top of page
Recent Posts

How to install and configure SMTP (Postfix) In Red Hat Enterprise Linux 7

The Simple Mail Transfer Protocol (SMTP) is a communication protocol for electronic mail transmission. The most commonly used implementations of SMTP in most Linux distributed OS are Sendmail and Postfix.

Postfix is an open source mail-transfer agent that was originally developed as an alternative to Sendmail and is usually set up as the default mail server. Let's start with Postfix.

Step:1 To verify the /etc/hosts file.

# cat /etc/hosts   localhost localhost.localdomain
::1     ip6-localhost ip6-loopback	mail

Step:2 To install Postfix rpm's or packages.

# yum install -y postfix

Step:3 To configure the Postfix as required.

# vi /etc/postfix/
::::::::::::: CUT SOME OUTPUT ::::::::::::: 
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
# Hostnames normally have prefixe Server
myhostname =
# The domain that is actually handling mail
mydomain =
inet_interfaces = localhost , $myhostname
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
unknown_local_recipient_reject_code = 550
#  The list of trusted remote SMTP servers that can relay through the server
mynetworks_style = subnet
mynetworks =,
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
	 ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.10.1/samples
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES

::::::::::::: CUT SOME OUTPUT ::::::::::::: 

Step:4 If Firewalld service is running, Need to open the ports in the OS firewall using following firewall-cmd commands.

# firewall-cmd --add-port=25/tcp --permanent
# firewall-cmd --reload

Step:5 To start the Postfix service.

# systemctl restart postfix
# systemctl enable postfix

Step:5 To verify the Postfix (SMTP) service from the client.

# telnet 25
Connected to
Escape character is '^]'.
220 ESMTP Postfix
250 2.1.0 Ok
250 2.1.5 Ok
354 End data with <CR><LF>.<CR><LF>
Subject: This is a test message 


This is a test message
250 2.0.0 Ok: queued as A611340B196
221 2.0.0 Bye
Connection closed by foreign host.

To check email from Postfix (SMTP) server by login with users.

# yum install mailx
# su - atower
$ mail
Heirloom Mail version 12.5 7/5/10.  Type ? for help.
"/var/spool/mail/atower": 1 message 1 new
>N  1 root@lab.munshibari.  Mon Jul 27 14:49  13/444   "This is a test message"
Message  1:
From  Mon Jul 27 14:49:33 2019
Return-Path: <>
Subject: This is a test message 
Status: R


This is a test message

This is a basic smtp email server configuration and will post some advanced configuration as well.

14 views0 comments

Recent Posts

See All


Log In to Connect With Members
View and follow other members, leave comments & more.
bottom of page