Cyberithub

6 Easy Steps to Install Sendmail Command in Linux (RHEL/CentOS 7/8)

Advertisements

In this article, I will take you through 6 Easy Steps to Install Sendmail Command in Linux. Now a days there are lot of open source tools are available like mutt, mail, mailx etc to send email from Linux command Line. One of the very basic tool available is sendmail. It is a very simple open source MTA(Mail Transfer Agent) in Linux which uses SMTP(Simple Mail Transfer Protocol) to send email.

One can either use this tool to send email manually through a command line or one can also use it within the Linux Bash Scripts. There are multiple ways through which this tool can be used. Now we are going to look into the steps in detail to install sendmail command in Linux.

6 Easy Steps to Install Sendmail Command in Linux (RHEL/CentOS 7/8) 1

Easy Steps to Install Sendmail Command in Linux

Also Read: 6 Easy Steps to Install Mutt Command in Linux (RHEL/CentOS 7/8)

Step 1: Prerequisites

a)You need to have running RHEL/CentOS 7/8 based Systems.

b)You should have yum tool installed in your System. Please Check Top 22 YUM Command Examples in RedHat/CentOS 7 to know more about yum utility.

c)You should have root or sudo access to run Privileged Commands. Please Check How to Add User to Sudoers to know more about providing sudo access to the User.

Step 2: Update Your System

If you are going to or planning to install a new package in your System then the first thing you need to do is to update your System using yum update -y command as shown below. This will update all the installed packages with the latest version so that all the dependent packages will remain fully updated.

[root@localhost ~]# yum update -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 9.0 kB 00:00:00
* base: mirrors.piconets.webwerks.in
* epel: download.nus.edu.sg
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package ca-certificates.noarch 0:2019.2.32-76.el7_7 will be updated
---> Package ca-certificates.noarch 0:2020.2.41-70.0.el7_8 will be an update
---> Package curl.x86_64 0:7.29.0-57.el7 will be updated
---> Package curl.x86_64 0:7.29.0-57.el7_8.1 install sendmail will be an update
---> Package dbus.x86_64 1:1.10.24-13.el7_6 install sendmail will be updated
---> Package dbus.x86_64 1:1.10.24-14.el7_8 will be an update
---> Package dbus-libs.x86_64 1:1.10.24-13.el7_6 install sendmail will be updated
---> Package dbus-libs.x86_64 1:1.10.24-14.el7_8 install sendmail will be an update
---> Package grub2.x86_64 1:2.02-0.81.el7.centos install sendmail will be updated
---> Package grub2.x86_64 1:2.02-0.86.el7.centos install sendmail will be an update
---> Package grub2-common.noarch 1:2.02-0.81.el7.centos will be updated
---> Package grub2-common.noarch 1:2.02-0.86.el7.centos will be an update
---> Package grub2-pc.x86_64 1:2.02-0.81.el7.centos will be updated
---> Package grub2-pc.x86_64 1:2.02-0.86.el7.centos will be an update
---> Package grub2-pc-modules.noarch 1:2.02-0.81.el7.centos will be updated
---> Package grub2-pc-modules.noarch 1:2.02-0.86.el7.centos will be an update
---> Package grub2-tools.x86_64 1:2.02-0.81.el7.centos will be updated
---> Package grub2-tools.x86_64 1:2.02-0.86.el7.centos will be an update
---> Package grub2-tools-extra.x86_64 1:2.02-0.81.el7.centos will be updated
---> Package grub2-tools-extra.x86_64 1:2.02-0.86.el7.centos will be an update
---> Package grub2-tools-minimal.x86_64 1:2.02-0.81.el7.centos will be updated
---> Package grub2-tools-minimal.x86_64 1:2.02-0.86.el7.centos will be an update
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.252.b09-2.el7_8 will be updated
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.262.b10-0.el7_8 will be an update

Step 3: Install Sendmail Command in Linux

Once the System is fully updated you can install sendmail tool in Linux using yum install sendmail -y command as shown below. This command will download and install the latest available sendmail package version from enabled Repository. If in case during the installation, you see any packages are broken then you can use --skip-broken option to skip the broken packages.

[root@localhost ~]# yum install sendmail -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 8.3 kB 00:00:00
* base: mirrors.piconets.webwerks.in
* epel: download.nus.edu.sg
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:01
(2/2): epel/x86_64/primary_db | 6.9 MB 00:00:11
Resolving Dependencies
--> Running transaction check
---> Package sendmail.x86_64 0:8.14.7-6.el7 will be installed
--> Processing Dependency: procmail for package: sendmail-8.14.7-6.el7.x86_64
--> Processing Dependency: libhesiod.so.0()(64bit) for package: sendmail-8.14.7-6.el7.x86_64
--> Running transaction check
---> Package hesiod.x86_64 0:3.2.1-3.el7 will be installed
---> Package procmail.x86_64 0:3.22-36.el7_4.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
sendmail x86_64 8.14.7-6.el7 base 737 k
Installing for dependencies:
hesiod x86_64 3.2.1-3.el7 base 30 k
procmail x86_64 3.22-36.el7_4.1 base 171 k

Transaction Summary
========================================================================================================================================================================
Install 1 Package (+2 Dependent packages)

Total download size: 938 k
Installed size: 2.0 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): hesiod-3.2.1-3.el7.x86_64.rpm | 30 kB 00:00:00
(2/3): procmail-3.22-36.el7_4.1.x86_64.rpm | 171 kB 00:00:00
(3/3): sendmail-8.14.7-6.el7.x86_64.rpm | 737 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.1 MB/s | 938 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : hesiod-3.2.1-3.el7.x86_64 1/3
Installing : procmail-3.22-36.el7_4.1.x86_64 2/3
Installing : sendmail-8.14.7-6.el7.x86_64 3/3
Verifying : procmail-3.22-36.el7_4.1.x86_64 1/3
Verifying : hesiod-3.2.1-3.el7.x86_64 2/3
Verifying : sendmail-8.14.7-6.el7.x86_64 3/3

Installed:
sendmail.x86_64 0:8.14.7-6.el7

Dependency Installed:
hesiod.x86_64 0:3.2.1-3.el7 procmail.x86_64 0:3.22-36.el7_4.1

Complete!

Step 4: Check Sendmail Command Version

There are multiple ways through which you can check sendmail utility version but the simplest way to check it by using below sendmail command. As you can see from the output current installed version is 8.14.7.

[root@localhost ~]# sendmail -d0.4 -bv root | grep Version
Version 8.14.7

Step 5: Send Email using Sendmail command in Linux

If you want to send email from Linux Command Line then you can use sendmail command as shown below. In this example, we are sending email to example@cyberithub.com with Message "Hi, This is from CyberITHub" and Subject "Test Email".

[root@localhost ~]# echo "Hi,This is from CyberITHub" | sendmail -s "Test Email" example@cyberithub.com

"Hi, This is from CyberITHub" : Message Body

-s : Subject of the email. More can be checked on sendmail Man Page.

"Test Email" : Email Subject

"example@cyberithub.com" : Receipient Email Id

Step 6: Check Man Page of sendmail command in Linux

If you want to check Man Page of sendmail command in Linux then you need to use man sendmail command as shown below. Man page provides a whole lot of information about some command so it comes handy whenever you want to explore more and check all the other options available with that command.

[root@localhost ~]# man sendmail
MAILQ(1) General Commands Manual MAILQ(1)

NAME
mailq - print the mail queue

SYNOPSIS
mailq [-Ac] [-q...] [-v]

DESCRIPTION
Mailq prints a summary of the mail messages queued for future delivery.

The first line printed for each message shows the internal identifier used on this host for the message with a possible status character, the size of the
message in bytes, the date and time the message was accepted into the queue, and the envelope sender of the message. The second line shows the error mes‐
sage that caused this message to be retained in the queue; it will not be present if the message is being processed for the first time. The status charac‐
ters are either * to indicate the job is being processed; X to indicate that the load is too high to process the job; and - to indicate that the job is too
young to process. The following lines show message recipients, one per line.

Mailq is identical to ``sendmail -bp''.

The relevant options are as follows:

-Ac Show the mail submission queue specified in /etc/mail/submit.cf instead of the MTA queue specified in /etc/mail/sendmail.cf.

-qL Show the "lost" items in the mail queue instead of the normal queue items.

 

 

 

Popular Recommendations:-

How to Create Table in MySQL 5.5 with Easy Steps

How to Disable IPV6 on Linux (CentOS / RHEL 7/8) Using 4 Best Steps

How to Set MariaDB root Password in RHEL/CentOS 7/8 Using Simple mysql_secure_installation

Introduction to SQL Injection Attacks in MySQL (v5.5)

How to Limit CPU Limit of a Process Using CPULimit in Linux (RHEL/CentOS 7/8)

How to Install Rust Programming Language in Linux Using 6 Best Steps

Openssl Tutorial: Generate and Install Certificate on Apache Server in 8 Easy Steps

How to Enable or Disable SELinux Temporarily or Permanently on RedHat/CentOS 7/8

Top 12 Nmap Commands to Scan Remote Host with Best Practices

Leave a Comment