Trending News

Blog

How to Easily Install and Configure Sendmail on CentOS/RHEL 7/RHEL 6
CentOS

How to Easily Install and Configure Sendmail on CentOS/RHEL 7/RHEL 6 

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/sendmail.mc, comment out the line below to allow receiving email from anywhere. Simply type dnl at the beginning of a line in sendmail.mc to comment it.
				
					dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

				
			
  1. Add this line above the ‘MAILER’ option in sendmail.mc as well.
				
					FEATURE(`relay_hosts_only')dnl

				
			
  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/sendmail.mc > /etc/mail/sendmail.cf

				
			

Restart the Sendmail service

				
					/etc/init.d/sendmail restart

				
			

4. Configure e-mail routing based on a domain

  1. Support@mydomain.com receives all emails addressed to the @example.com domain.
				
					@example.com support@mydomain.com

				
			
  1. All emails sent to support@mydomain.com will be sent to jack, the local user.
				
					support@mydomain.com  jack

				
			
  1. All emails sent to @mydomain.com will be forwarded to the domain @otherdomain.com, along with usernames.
				
					@mydomain.com    %1@otherdomain.com

				
			
  1. All emails sent to @otherdomain.com will be ignored by my mail server, with a note acknowledging the sender.
				
					@otherdomain.com 	 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 *