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.

[stextbox id=”Default” mode=”css” bwidth=”7″ color=”FFFFFF” ccolor=”000000″ bcolor=”1A52EA” bgcolor=”000000″ bgcolorto=”000000″   image=”null”]

[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 [/stextbox]


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:

[stextbox id=”Default” mode=”css” bwidth=”7″ color=”FFFFFF” ccolor=”000000″ bcolor=”1A52EA” bgcolor=”000000″ bgcolorto=”000000″   image=”null”]define(`SMART_HOST’, `smtpqf.com’)dnl [/stextbox]

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


3] Compile with m4 Command:

[stextbox id=”Default” mode=”css” bwidth=”7″ color=”FFFFFF” ccolor=”000000″ bcolor=”1A52EA” bgcolor=”000000″ bgcolorto=”000000″   image=”null”]

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


4] Now, Start the Sendmail Service:

[stextbox id=”Default” mode=”css” bwidth=”7″ color=”FFFFFF” ccolor=”000000″ bcolor=”1A52EA” bgcolor=”000000″ bgcolorto=”000000″   image=”null”]

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


5] Enable the Sendmail Service Permanently:

[stextbox id=”Default” mode=”css” bwidth=”7″ color=”FFFFFF” ccolor=”000000″ bcolor=”1A52EA” bgcolor=”000000″ bgcolorto=”000000″   image=”null”]

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


6] To put Entires in /etc/hosts file

[stextbox id=”Default” mode=”css” bwidth=”7″ color=”FFFFFF” ccolor=”000000″ bcolor=”1A52EA” bgcolor=”000000″ bgcolorto=”000000″   image=”null”]

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

10.10.10.10       smtpqf.com[/stextbox]


7] Check for the Sendmail connectivity in the Server :

[stextbox id=”Default” mode=”css” bwidth=”7″ color=”FFFFFF” ccolor=”000000″ bcolor=”1A52EA” bgcolor=”000000″ bgcolorto=”000000″   image=”null”]

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


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

[stextbox id=”Default” mode=”css” bwidth=”7″ color=”FFFFFF” ccolor=”000000″ bcolor=”1A52EA” bgcolor=”000000″ bgcolorto=”000000″   image=”null”]

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


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

[stextbox id=”Default” mode=”css” bwidth=”7″ color=”FFFFFF” ccolor=”000000″ bcolor=”1A52EA” bgcolor=”000000″ bgcolorto=”000000″   image=”null”]

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)[/stextbox]


 

 

You may also like...

Leave a Reply