How to Setup Sendmail on Kali Linux & CentOS
This guide will walk you through setting up Sendmail on both Kali Linux and CentOS operating systems. Sendmail is a common Mail Transfer Agent (MTA) used for delivering email on Unix-like systems.
We will cover the necessary steps for installation, configuration, and basic testing of Sendmail on each distribution.
Kali Linux
Installation
Install Sendmail using the following command:
sudo apt-get update
sudo apt-get install sendmail sendmail-cf
Configuration
After installation, configure Sendmail by editing the /etc/mail/sendmail.mc
file. Modify the DAEMON_OPTIONS line to listen on all interfaces:
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
dnl to
DAEMON_OPTIONS(`Port=smtp, Name=MTA, Family=inet, Address=0.0.0.0')dnl
Run the following command to regenerate the sendmail.cf
file:
sudo m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Restart Sendmail
Restart the Sendmail service:
sudo systemctl restart sendmail
CentOS
Installation
Install Sendmail using the yum
package manager:
sudo yum update
sudo yum install sendmail sendmail-cf m4
Configuration
Similar to Kali Linux, configure Sendmail by modifying /etc/mail/sendmail.mc
. Adjust the DAEMON_OPTIONS:
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
dnl to
DAEMON_OPTIONS(`Port=smtp, Name=MTA, Family=inet, Address=0.0.0.0')dnl
Generate the sendmail.cf
file:
sudo m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Restart Sendmail
Start and enable the Sendmail service:
sudo systemctl start sendmail
sudo systemctl enable sendmail
Testing Sendmail
You can test Sendmail using the mail
command. Replace your_email@example.com
with a valid email address:
mail your_email@example.com
Subject: Test Email
This is a test email from Sendmail.
.
The single dot (.
) on a line by itself indicates the end of the message.
Check your email inbox to confirm that the email was successfully sent.