[Complete Guide] How to Install Sendmail Server on Centos 7?

 In All Tutorials
Last Updated On October 04, 2019

Sendmail is a feature-rich MTA (Mail Transfer Agent) uses SMTP protocol for sending mail. Though Sendmail has been replaced by postfix in modern RHEL versions it is widely used in RHEL 5 or its earlier version. Sendmail is recommended by most of the system administrator as an MTA(Mail transfer agent) server over other MTAs.

Prerequisites Before you Install Sendmail Server on Centos 7 

Highly recommended to have root privileges in order to perform the below steps:

Step 1: 

Add the centos 7 EPEL repositories, open terminal and paste the below command:

sudo yum install epel-release

Step 2:

Install Sendmail with dependency from yum package manager

sudo yum install sendmail sendmail-cf m4

(Note: m4 is a macro processor you need to use to compile Sendmail configuration file. )

Once the installation is done, you will be getting output like this:

Transaction Summary
=================================================
Install 3 packages
Total download size: 1.2 M
Installed size: 3.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): sendmail-cf-8.14.7-5.el7.noarch.rpm                                                                                                        | 186 kB  00:00:00
(2/3): m4-1.4.16-10.el7.x86_64.rpm                                                                                                                | 256 kB  00:00:00
(3/3): sendmail-8.14.7-5.el7.x86_64.rpm                                                                                                           | 736 kB  00:00:01
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                    888 kB/s | 1.2 MB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : m4-1.4.16-10.el7.x86_64                                                                                                                               1/3
  Installing : sendmail-8.14.7-5.el7.x86_64                                                                                                                          2/3
  Installing : sendmail-cf-8.14.7-5.el7.noarch                                                                                                                       3/3
  Verifying  : sendmail-8.14.7-5.el7.x86_64                                                                                                                          1/3
  Verifying  : sendmail-cf-8.14.7-5.el7.noarch                                                                                                                       2/3
  Verifying  : m4-1.4.16-10.el7.x86_64                                                                                                                               3/3
Installed:
  m4.x86_64 0:1.4.16-10.el7                          sendmail.x86_64 0:8.14.7-5.el7                          sendmail-cf.noarch 0:8.14.7-5.el7
Complete!

OR

rpm -qa | grep sendmail

Step 3: Configure sendmail server 

Before directly edit /etc/mail/sendmail.mc for configuration we need to understand important file existence in /etc/mail directory.

  • access: allowing or denying other systems to use Sendmail for outbound emails.
  • domaintable: used for domain name mapping for Sendmail.
  • local-host-names: used to define an alias for a host.
  • mailertable: used to override routing for particular domains.
  • virtusertable: allowing multiple virtual domains to be hosted on one machine.

Make the following changes in sendmail.mc file below is the command:

vim /etc/mail/sendmail.mc

define(`SMART_HOST', `smtp.gmail.com')dnl 

Note: Set your SMTP hostname above 

#Add the below two lines in your sendmail.mc file to listen on port 465 and 587:

define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl 

 

#Uncomment the below lines:

TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl 

 

#Add the below lines:

FEATURE(`authinfo', `hash /etc/mail/auth/client-info.db')dnl
FEATURE(`access_db', `hash -T<TMPF> -o /etc/mail/access.db')dnl
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl 

 

#Uncomment for Sendmail to listen on port 587

DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl 

 

#Uncomment for sendmail to listen on port 587

DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl 

 

#Mention your domain and uncomment

MASQUERADE_AS(`mydomain.com')dnl

Save and exit the file.

Step 4: Make Auth Directory

By assigning proper permission to make auth directory inside /etc/mail

sudo mkdir /etc/mail/auth
cd /etc/mail/auth

Create a new file client-info and below auth in the file.

vim client-info
AuthInfo:gmail.com "U:username" "P:password" "M:PLAIN"
AuthInfo: "U:username" "P:Password" "M:PLAIN
makemap -r hash client-info.db < client-info

Add your relay IP

vi /etc/mail/access

Connect: [your-ip ]  RELAY

# Check the /usr/share/doc/sendmail/README.cf file for a description
# of the format of this file. (search for access_db in that file)
# The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
# package.
# If you want to use AuthInfo with "M:PLAIN LOGIN", make sure to have the
# cyrus-sasl-plain package installed.
# By default we allow relaying from localhost...
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY

Step 5: Recompiling Sendmail Configuration

Update Sendmail configuration by compiling the /etc/mail/sendmail.mc file using m4 macro processor.

sudo m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

OR

sudo make -C /etc/mail

Once you have recompiled restart the service using below command.

sudo service sendmail restart

Step 6: Send your First Email

sendmail -v myemailid@gmail.com

Pro tip: 

You might face this common problem 

Disabling HOST statistics file(/var/lib/sendmail/host_status).
Creating /etc/mail/sendmail.cf...
Creating /etc/mail/submit.cf...
Informational: confCR_FILE file empty: /etc/mail/relay-domains
Informational: confCT_FILE file empty: /etc/mail/trusted-users
Updating /etc/mail/access...
Updating /etc/mail/aliases...
WARNING: local host name (ixtmixilix) is not qualified; see cf/README: WHO AM I?

This issue occurs when your hostname/domain name is not mapped with your server.  It's a warning, that your hostname won’t work outside your local network.  

You can simply set your hostname to a registered domain by using below command.

hostnamectl set-hostname my.new-hostname.server

I hope you liked this article where I tried to explain everything in the most layman manner. Using these simple steps you can install Sendmail Server on Centos.

In case of any query, please feel free to comment below.

Recent Posts

Leave a Comment

We are always looking for fresh talent to contribute to our blog. If you have a knack for writing and a passion for email marketing, we would love to have your post on our Guest Blog .

Submit a Guest Post
Pepi thinking

Start typing and press Enter to search

Thank you for your details!

Fill out your information below, and we will send you a PepiAlert, that will describe your domain’s email deliverability situation. Please note that your email address must match the domain, or the domain must be owned by the company matching the email address. We have the right to refuse the request, if we can’t verify the information.

*All fields are required



Pin It on Pinterest