[No audio]
Sendmail. Sendmail is another one of
the major service that is used in Linux
or Unix environment. Sendmail is a
program that is run in your Linux
systems to send emails and receive
emails. But I would say primarily it is
used to send emails. Because when you
have a program running in your system or
or a workflow running in your system,
and you do wanted to be notified if this
if the process finished, or if the whole
workflow finished successfully, you do
want to get an email at the end. That's
when you actually have to have some kind
of mailing program. And the most and
readily used program that runs in
Linux is sendmail. So the purpose is,
again to send and receive emails, the
files that the configuration files of
sendmail is /etc/mails/sendmail.mc,
which is the main file. mc stands for
mail configuration. And you configure
everything in this and once you actually
compile this configuration file, it
sends all its configuration to /etc/mails/sendmail.cf,
Many people go straight to sendmail.cf, which is also
okay, it's fine. It's nothing that
you're going to break anything. But it
is a standard and practical
way that you should always go to sendmail.mc,
and then compile it, start the
system, start that sendmail, and it
automatically push the changes out to
the configuration file. All the
configuration file of sendmail is
located, all the files are located in et
/etc/mail directory. The service that you
need to run or start with your system
start and stop program is systemctl
restart sendmail. Sendmail is one of
those programs that does not have d at
the end. But it does not mean that it's
not running at all times. It does run in
the background, it is still a daemon, but
it's somehow never got a d at the end.
The command that you will run if you
want to send email out from your server
would be mail -s which is an
option, and then quotes, you'll put a
subject line followed by the email
address that you are sending it to. Once
you send it and hit return on your
keyboard, it will bring you a kind of
interactive or like vi kind of mode
where you will type everything. And then
once you're done, then you will just
simply do Ctrl D, and it will get you
out of that mail program, and it will
send the email out. So to illustrate
that more, we will we'll get into our
Linux machine. And we will look at some
of the files and commands are related to
sendmail. So we have our server here,
we'll log in as ourself, and most likely
it has already logged in as root. How do
we verify it, we'll just run whoami,
which is a command that tells you which
user is logged in. I'm gonna move the
window to the side. So we'll see exactly
what we're doing based on our slide in
the back. So the first configuration
file is sendmail. But of course, before
we get into the files, the first thing
we need to do, is we need to find out
whether we have the sendmail program
installed in our system. And how do we
need to find that out? There is a command
that you run rpm -qa, and then
you grep for sendmail. rpm -qa
list every single program or repository
or package that you have installed in
your system. So I ran it I see it it's
not there. So the next thing we'll do is
we will install it to install a package
you will run yum install sendmail.
And of course remember that this is
going to go outside on the internet
where all the CentOS repositories are
located and it will get that package
from there. If you do not have internet
access on your Linux machine, it's not
going to work it will fail, it will say, Cannot
reach the internet or cannot reach the
repositories mirrors. So once I run yum
install sendmail, it's telling me that
it found one package and the size, do you
want to install it? Yes, of course I do
want to install it. I'll click Yes. And it
will start installing it, download,
install, verify, cleanup, all that stuff is going to go through.
[No audio]
Okay, the installation of sendmail is
completed. Anyway, there is an another
package that you do need to install,
which does the configuration of your
sendmail. And that is sendmail-cf.
[No audio]
Click yes to install it.
[No audio]
Okay, it is
complete, it's awesome. So once you have
the package installed, it means it
already creates your directories for you
where they belong, it already creates a
configuration file for you. So the first
thing we have to do is go to
configuration file to define its
configuration parameters. The
configuration files, all of them are
located in /etc/mail, and you will see
right here, the first third one from the
top, it says sendmail.mc. This is where
we will define our mail relay server.
And what is a mail relay server. Mail
relay server is a server that is set up
in a company and environment which will
accept your emails that are coming from
any of the server and then deliver. It's
like a middleman which takes, on the left
hand it takes your message, on the right
hand it delivers it. It's a server as
well. Sometimes it's a Windows Server,
sometimes it's Linux server depending on
your environment, but it's a mail relay
server. Okay, so when we come down to
this file, anything that starts with
dnl, it means that it's just a comment,
you can ignore that, we have to come
down to a line where it says define some
SMART_HOST. And the SMART_HOST is our
SMTP server or relay server where we are
going to send our emails and it's going
to accept it. So you just put the host
name with a fully qualified domain name,
meaning the host name dot your domain
name.com, you will add it here. Once that
is added, and next thing you have to do
is you have to start the service.
systemctl restart or start sendmail.
[No audio]
Okay, the sendmail service has
restarted. Let's check the status. It
says it's up and running. You can also
check the status of sendmail by running
the command ps -ef. And then you
could just simply grep for sendmail. And
here it will tell you the second one,
the first one is just telling you the it
is accepting connections. And this is
the main process that runs it. You will
kill it by typing the command kill
followed by the process ID, 6023. Now you
could send emails and the command to
send email is mail -s subject line
is mail setup. And I want to send it to
myself. So I'll put my email which is
imran_ny@hotmail.com. I hit enter. And
once I hit enter and that's where the
mail body is. Whatever that you want to
type the text goes in. hi hellow
goodbye. And once it's done, all you
have to do is type Ctrl D, Ctrl D is
typed, you will get out of your mail
program, and that's how you send and
configure your mail. Mail again, once
again, it's one of the critical services
that oftentimes you do have to configure
in your system. So familiarize yourself
with the mail files, the configuration,
the how to start and stop this mail
service, and how to monitor it and how to send mails
[No audio]