Skip to content

Instantly share code, notes, and snippets.

@marshki
Last active December 19, 2023 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshki/3b3d8657046d25eaac4e7f23690e3a92 to your computer and use it in GitHub Desktop.
Save marshki/3b3d8657046d25eaac4e7f23690e3a92 to your computer and use it in GitHub Desktop.
Setup Sendmail in GNU/Linux.

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):

CentOS, Fedora 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 /etc/mail/submit.mc /etc/mail/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 > submit.cf

Modify /etc/hosts file

More goodness.

  • List the host's IP & hostname (IPaddress hostname alias), e.g.:

127.0.1.1 foobar.psych.nyu.edu foobar foo

  • List an SMTP client (choose 1):

128.122.112.26 calaf.cns.nyu.edu calaf mailhost 128.122.108.240 smtp.nyu.edu mailhost 216.165.47.33 smtp.nyu.edu nyu mailhost

:neckbeard:❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment