Trending News


How to Easily Install and Configure Sendmail on CentOS/RHEL 7/RHEL 6 [ Easy Guide ]

How to Easily Install and Configure Sendmail on CentOS/RHEL 7/RHEL 6 [ Easy Guide ] 

Sendmail is an MTA (Mail Transfer Agent) server that is used to transfer email from one host to another. The SMTP (Simple Mail Transfer Protocol) protocol is used by Sendmail. The majority of device administrators favor Sendmail as an MTA to other MTAs.

Table of Contents

Sendmail was the default mail server in RHEL 5 and earlier versions, but later versions of RHEL-based systems adopted postfix as the default mail server. The majority of users are comfortable with Sendmail and want to continue using it with version 6. This article will guide users through the process as to how you can install and configure Sendmail on CentOS/RHEL 7/RHEL 6.

1. Install Sendmail

If you do not already have Sendmail installed, use the yum package manager to install it along with the other required packages.

					yum install sendmail sendmail-cf m4


2. Configuring Sendmail Server

Before we begin configuring Sendmail server, we need to be aware of the different Sendmail configuration files located in the /etc/mail directory.

  • access — Allow or deny other systems from using Sendmail to send outbound emails.
  • domaintable — For Sendmail, this is used to map domain names.
  • local-host-names — The host’s aliases are defined here.
  • mailertable — The instructions that override routing for specific domains.
  • virtusertable — Allows several virtual domains to be hosted on a single machine by specifying a domain-specific type of aliasing.
  1. In /etc/mail/, comment out the line below to allow receiving email from anywhere. Simply type dnl at the beginning of a line in to comment it.
					dnl DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')dnl

  1. Add this line above the ‘MAILER’ option in as well.

  1. 2.3 Fill in the full hostname of your computer in this format.
					hostname >> /etc/mail/relay-domains

  1. 2.3 Fill in the full hostname of your computer in this format.

3. Recomompile the Sendmail Configuration

The Sendmail configuration files are compiled using the m4 macro processor. As M4 is stream-based, it does not understand lines.

					m4 /etc/mail/ > /etc/mail/


Restart the Sendmail service

					/etc/init.d/sendmail restart


4. Configure e-mail routing based on a domain

  1. receives all emails addressed to the domain.

  1. All emails sent to will be sent to jack, the local user.

  1. All emails sent to will be forwarded to the domain, along with usernames.

  1. All emails sent to will be ignored by my mail server, with a note acknowledging the sender.
 	 error:nouser User unknown
After you have made all of your changes to virtusertable, run the following command to generate an updated virtusertable.db file with your new configuration.
					makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable


Now Restart the Sendmail service with the following command

					/etc/init.d/sendmail restart


Thank you for taking the time to read this article. I hope you found this article useful in installing and configuring Sendmail on CentOS and Red Hat systems.

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on reddit
Share on vk
Share on tumblr
Share on skype
Share on stumbleupon
Share on whatsapp

Related posts

Leave a Reply

Required fields are marked *