How to configure Sendmail in Linux

Sendmail’s core purpose, like other MTAs, is to safely transfer email among hosts, usually using the SMTP protocol. However, Sendmail is highly configurable, allowing control over almost every aspect of how email is handled, including the protocol used. Many system administrators elect to use Sendmail as their MTA due to its power and scalability.

In this post we are going to look on how to configure the Sendmail configuration using your mail server gateway.


My Local Server :

MY SMTP Server  : (

1] Install the sendmail packages and m4 packages.

[ ~]# yum install sendmail\*
Loaded plugins: rhnplugin, security
This system is receiving updates from RHN Classic or RHN Satellite.
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package sendmail.x86_64 0:8.13.8-10.el5_11 set to be updated
—> Package sendmail-cf.x86_64 0:8.13.8-10.el5_11 set to be updated
—> Package sendmail-devel.i386 0:8.13.8-10.el5_11 set to be updated
—> Package sendmail-devel.x86_64 0:8.13.8-10.el5_11 set to be updated
—> Package sendmail-doc.x86_64 0:8.13.8-10.el5_11 set to be updated
–> Finished Dependency Resolution

Dependencies Resolved 

2] Sendmail’s lengthy and detailed configuration file is /etc/mail/send Avoid editing the file directly. To make configuration changes to Sendmail, edit the /etc/mail/ file, backup the original /etc/mail/ file, and use the following alternatives to generate a new configuration file:

#  cd /etc/mail/

Look for the line :26 and make the changes in the as below:

define(`SMART_HOST’, `’)dnl 

Where: is the name of my Mail Server Gateway

3] Compile with m4 Command:

[ ~]# m4 /etc/mail/ > /etc/mail/ 

4] Now, Start the Sendmail Service:

[ ~]#     /etc/init.d/sendmail start  

5] Enable the Sendmail Service Permanently:

[ ~]# chkconfig sendmail on 

6] To put Entires in /etc/hosts file

[ ~]# vi /etc/hosts

7] Check for the Sendmail connectivity in the Server :

[ ~] # netstat -antupl |grep -i sendmail
tcp 0 0* LISTEN 20388/sendmail: acc     

8] Now, we can try to send mail out from the Server to other recipients:

[ ~]# echo “This is message body” | mail -s “This is Subject”

9] To Check and confirm with the logs under /var/log/maillog:

May 8 15:40:29 sendmail[20444]: v487eTgX020444: from=root, size=61, class=0, nrcpts=1, msgid=<>, relay=root@localhost
May 8 15:40:29 sendmail[20445]: v487eTwo020445: from=<>, size=348, class=0, nrcpts=1, msgid=<>, proto=ESMTP, daemon=MTA, relay=localhost []
May 8 15:40:29 sendmail[20444]: v487eTgX020444:, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30061, relay=[] [], dsn=2.0.0, stat=Sent (v487eTwo020445 Message accepted for delivery)
May 8 15:40:29 sendmail[20447]: STARTTLS=client, relay=smtpcis., version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-SHA, bits=256/256
May 8 15:40:29 sendmail[20447]: v487eTwo020445: to=<>, ctladdr=<> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=120348, relay=smtpqf. [], dsn=2.0.0, stat=Sent (ok: Message 330662174 accepted)



Leave a Reply