Setup Sendmail in GNU/Linux
Scope: Set up a general-purpose internetwork routing facility that supports Simple Mail Transfer Protocol (SMTP).
Dependencies
Install these packages first, per your operating system (OS):
Fedora, CentOS | Debian, Ubuntu |
---|---|
dnf install |
apt-get install |
sendmail-cf | sendmail-cf |
mailutils | mailutils |
sendmail | sendmail |
Disable Sendmail daemon
Improve Sendmail security by turning it off.
systemctl stop sendmail
systemctl disable sendmail
Preflight checks
You'll need these.
- Check for required files:
ls /etc/mail/submit.*
should yield:
/etc/mail/submit.cf
/etc/mail/submit.mc
- Check for
m4
processor:
which m4
should yield:
/usr/bin/m4
Build submit.cf
file
The secret sauce.
- Backup
submit.cf
:
cp -pv /etc/mail/submit.cf /etc/mail/submit.cf.bak
- Create
mysubmit.mc
macro configuration file by copying default macro configuration file:
cp -pv submit.mc mysubmit.mc
- Modify
mysubmit.mc
,
replacing:
[127.0.0.1]
with:
mailhost
on the msp
line so that is looks like this:
FEATURE(`msp', `mailhost')dnl`
- Commit your change (from
/etc/mail
):
m4 mysubmit.mc > /etc/mail/submit.cf
Modify /etc/hosts
file
More goodness.
- List the host's IP & hostname, e.g.:
IPaddress hostname alias
- List an SMTP client:
IPaddress hostname alias
Cheers.