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.

Whereas:

My Local Server : quickfixlinux.com

MY SMTP Server  : smtpqf.com (10.10.10.10)

1] Install the sendmail packages and m4 packages.

[root@quickfixlinux.com ~]# 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 mail.cf. Avoid editing the sendmail.cf file directly. To make configuration changes to Sendmail, edit the /etc/mail/sendmail.mc file, backup the original /etc/mail/sendmail.cf 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 sendmail.mc as below:

define(`SMART_HOST’, `smtpqf.com’)dnl 

Where: smtpqf.com is the name of my Mail Server Gateway


3] Compile with m4 Command:

[root@quickfixlinux.com ~]# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf 


4] Now, Start the Sendmail Service:

[root@quickfixlinux.com ~]#     /etc/init.d/sendmail start  


5] Enable the Sendmail Service Permanently:

[root@quickfixlinux.com ~]# chkconfig sendmail on 


6] To put Entires in /etc/hosts file

[root@quickfixlinux.com ~]# vi /etc/hosts

10.10.10.10       smtpqf.com


7] Check for the Sendmail connectivity in the Server :

[root@quickfixlinux.com ~] # netstat -antupl |grep -i sendmail
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 20388/sendmail: acc     


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

[root@quickfixlinux.com ~]# echo “This is message body” | mail -s “This is Subject” quickfixlinux@gmail.com


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

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


 

 

You may also like...

Leave a Reply