• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install Sendmail Server on CentOS/RHEL 7/6/5

Written by Rahul, Updated on January 19, 2015
Mail Servers, Sendmail dovecot, m4, mail, sendmail, virtusertable

Sendmail is a MTA (Mail Transfer Agent) server used for transferring email from between different hosts. Sendmail uses SMTP (Simple Mail Transfer Protocol) protocol. Most of system administrators preferred to use Sendmail server as MTA than other MTAs.

RHEL 5 or its earlier versions were using Sendmail as default mail server, But newer version’s of RHEL based systems adapted postfix as default mail server. Most of users are familiar with Sendmail and want to use it with version 6 also. This article will help that users for installing Sendmail server on RHEL 7/6/5 or with minimal configuration.

Installing Required Packages

If you don’t have installed Sendmail using following command to install Sendmail with other required packages using yum package manager.

# yum install sendmail sendmail-cf m4

Configure Sendmail Server

Before starting configuration we must know about various Sendmail configuration files exists in /etc/mail directory.

  • access — Allow/Deny other systems to use Sendmail for outbound emails.
  • domaintable — Used for domain name mapping for Sendmail.
  • local-host-names — Used to define aliases for the host.
  • mailertable — Defined the instructions that override routing for particular domains.
  • virtusertable — Specifies a domain-specific form of aliasing, allowing multiple virtual domains to be hosted on one machine.
  • 2.1 Comment out below line in /etc/mail/sendmail.mc to allow receiving email from anywhere. To comment a line in sendmail.mc, just put dnl at start of line.

    dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
    

    2.2 Add this line also in sendmail.mc above ‘MAILER’ option

    FEATURE(`relay_hosts_only')dnl
    

    2.3 Add your PC’s full hostname in this file.

    # hostname >> /etc/mail/relay-domains
    

    Recompile Sendmail Configuration

    m4 ia a macro processor to compile the Sendmail configuration files. m4 is stream-based, that is, it doesn’t understand about lines.

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

    Restart Sendmail service

    # /etc/init.d/sendmail restart
    

    Configure Domain based E-mail Routing

    As we read above that virtusertable file used for aliasing, allowing multiple virtual domains to be hosted on one machine.

    1. All emails addressed to @example.com domain delivered to [email protected]

    @example.com [email protected]
    

    2. All emails addressed to [email protected] will forward to local user jack.

    [email protected]  jack
    

    3. All emails addressed to @mydomain.com will forward to domain @otherdomain.com with corresponding usernames.

    @mydomain.com    %[email protected]
    

    4. All emails addressed to @otherdomain.com will be rejected my mail server with acknowledging sender with message

    @otherdomain.com 	 error:nouser User unknown
    

    After making all changes in virtusertable execute following command to create updated virtusertable.db file containing the new configuration.

    # makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable
    

    Now restart Sendmail service

    # /etc/init.d/sendmail restart
    

    Thanks for reading this article. I hope this article will help you to configure Sendmail on CentOS and Red Hat systems..

    References:
    http://www.sendmail.com/
    http://www.sendmail.com/sm/open_source/docs/m4/intro_m4.html

    Share it!
    Share on Facebook
    Share on Twitter
    Share on Google+
    Share on Reddit
    Share on Tumblr
    Rahul
    Rahul
    Connect on Facebook Connect on Twitter Connect on Google+

    I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

    Related Posts

    • How to Install Postal Mail Server on Ubuntu 16.04 & 14.04

      May 19, 2017
    • How to Transfer Mailboxes Between IMAP Servers with Imapsync

      May 13, 2017
    • How to Install and Use Imapsync on Ubuntu & Debian

      May 12, 2017
    • How to Install and Use Imapsync on CentOS & Fedora

      May 6, 2017
    • How to Setup Mail Forwarding in Postfix

      January 5, 2016

    8 Comments

    1. john Reply to john
      August 17, 2017 at 2:27 pm

      Is your comment still accurate, and why?

      “Most of system administrators preferred to use Sendmail server as MTA than other MTAs.”

      Is this more a function of it’s already found in the OS release they have installed so it’s convenient more than it is the best solution?

      At this point it seems antiquated it’s been a while since an update as well, one of the biggest gaps in support since proofpoint took it over.

      I know this thread is kinda old, but you did good work on this and I thought I’d ask if you still felt the same way about it.

    2. glen Reply to glen
      May 12, 2015 at 1:03 am

      Comment out below line in /etc/mail/sendmail.mc to allow receiving email from anywhere.
      dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl

      Add this line also in sendmail.mc above ‘MAILER’ option
      FEATURE(`relay_hosts_only’)dnl

      where are you supposed to put “FEATURE(`relay_hosts_only’)dnl”
      i couldnt find ‘MAILER’ option anywhere when i searched for it & i dont know what to look for?

    3. Anthony Reply to Anthony
      March 24, 2014 at 9:47 am

      Thanks for the write-up but I was unable to get this working on my Fedora 19 system. I was getting some relaying denied errors. I then found this http://www.rosehosting.com/blog/install-and-configure-a-simple-mail-server-using-sendmail-and-dovecot-on-a-fedora-20-vps/ which worked just fine so I thought I will share it here as your article comes up in the top 10 when searching for ‘how to install sendmail and dovecot’ and I’m sure it will be useful to someone else.

      Thanks again,

      Anthony

      • eBay Cashback Sidebar Reply to eBay
        November 14, 2016 at 11:27 pm

        Thx you for this tutorial but its not work for me either
        i tried the posfix solution from Anthony and all is ok now 🙂
        thx u

    4. Tim Reply to Tim
      February 23, 2014 at 7:21 pm

      Thanks for the tutorial, but I get a segfault when trying to start the sendmail service
      “Starting sendmail: /bin/bash: line 1: 16563 Segmentation fault /usr/sbin/sendmail -bd -q1h”

    5. Yazir Arafath Reply to Yazir
      February 2, 2014 at 2:57 pm

      I couldn’t find mail_location = mbox:~/mail:INBOX=/var/mail/%u in dovecot.conf file.

    6. Lizette Reply to Lizette
      January 11, 2014 at 9:46 am

      Pretty! This has been a really wonderful article.
      Thank you for providing these details.

    7. Swapnesh Kupwade Reply to Swapnesh
      October 10, 2013 at 10:48 am

      Thanks for the post.

    Leave a Reply

    Cancel reply

    Popular Posts

    • How to Setup Squid Proxy Server on Ubuntu 18.04 & 16.04
    • How To Install Zabbix Agent on Debian 9/8
    • How to Install and Configure Squid Proxy on Debian 9
    • How to Remove “public/index.php” from URL in Laravel
    • How To Install Wine 3 on Debian 9 (Stretch)
    All rights reserved. © 2013-2018 TecAdmin.net. This site uses cookies. By using this website you agree our term and services