Outgoing emails w/ Sendmail

Warning: this is NOT an MX setup. We are merely relaying through a smarthost on the LAN in plain-text (without STARTTLS)

tested on Slackware 14.2 current/extra

FQDN workaround

I like short hostnames hence I had trouble with Sendmail which needs an FQDN. I worked around it by adding .localdomain to the configuration and it goes through.

In any case, the sender gets checked at the receiving MX. Therefore, you might have to play with masquerading on your outbound relay and fix Return-path.

System preparation

vi /etc/hosts

x.x.x.x      HOST.localdomain HOST
x.x.x.x      SMARTHOST
x.x.x.x      GW



cp -pi /etc/mail/aliases /etc/mail/aliases.dist
echo root: REAL-EMAIL-ADMIN >> /etc/mail/aliases
cat /etc/mail/aliases

Outbound sendmail setup

cp -pi /etc/mail/sendmail.cf /etc/mail/sendmail.cf.dist

the quick & dirty way

vi /etc/mail/sendmail.cf

O DaemonPortOptions=Addr=, Name=MTA
#O DaemonPortOptions=Port=587,Addr=, Name=MSA, M=E


with macros

grep -v ^dnl /usr/share/sendmail/cf/cf/sendmail-slackware.mc | sed 's/dnl$//' > /usr/share/sendmail/cf/cf/custom.mc
vi /usr/share/sendmail/cf/cf/custom.mc

at the end of defines

#DAEMON_OPTIONS(`Port=587,Addr=, Name=MSA, M=E')

at the end of FEATUREs


generate the conf

cd /usr/share/sendmail/cf/cf/
m4 custom.mc > /etc/mail/sendmail.cf
diff -bu /etc/mail/sendmail.cf.dist /etc/mail/sendmail.cf | grep ^+.

another way to update the conf (as advertised into the originating sendmail.cf)

cp sendmail-slackware.mc /usr/share/sendmail/cf/config.mc
cd /usr/share/sendmail/cf
sh Build config.cf
cp config.cf /etc/mail/sendmail.cf

…you might notice Dj and DS have changed

Ready to go

now check the configuration, enable and restart the daemon

newaliases #also warns about FQDN
sendmail -d0.1 -bt < /dev/null
ls -lF /etc/rc.d/rc.sendmail
chmod +x /etc/rc.d/rc.sendmail
/etc/rc.d/rc.sendmail start

Mail should pass through your dedicated internal network relay

tail -F /var/log/maillog
date | mail -s `uname -n` root

re-process the queue

sendmail -v -q


My unqualified host name (slack9) unknown; sleeping for retry

==> simply adding .localdomain in sendmail.cf, not even in /etc/hosts. We like short hostnames on the LAN. DNS is NOT the only way to deal with naming.

Although the smarthost is properly defined with A and PTR public DNS records, the return-path get’s checked at the receiving MX

Oct 17 13:08:20 malabar postfix/smtpd[17546]: NOQUEUE: reject: RCPT from std30.os3.su[]: 554 5.1.8 <root@slack9.localdomain>: Sender address rejected: Domain not found; from=<root@slack9.localdomain> to=<pbraun@nethence.com> proto=ESMTP helo=<std30.os3.su>

==> do DOMAIN MASQUERADING on the relay


Sendmail Open Source https://www.proofpoint.com/us/open-source-email-solution

Forward-confirmed reverse DNS https://en.wikipedia.org/wiki/Forward-confirmed_reverse_DNS

Setup a SmartHost in Linux Sendmail https://rick.cogley.info/post/setup-smarthost-in-linux-sendmail/

Configuring sendmail https://etutorials.org/Linux+systems/red+hat+linux+bible+fedora+enterprise+edition/Part+IV+Red+Hat+Linux+Network+and+Server+Setup/Chapter+19+Setting+Up+a+Mail+Server/Configuring+sendmail/

E.3. m4 sendmail Macros https://docstore.mik.ua/orelly/networking_2ndEd/tcp/appe_03.htm

Force sendmail to deliver a message in sendmail’s mail queue https://www.cyberciti.biz/tips/force-sendmail-to-deliver-a-message-in-sendmails-mail-queue.html

How do I change the sendmail ‘from’ address and domain on the appliance emails? https://unitrends-support.force.com/UnitrendsBackup/articles/How_To/000004131

How to Specify outgoing HELO with sendmail? https://serverfault.com/questions/205271/how-to-specify-outgoing-helo-with-sendmail





Open-Sendmail http://open-sendmail.sourceforge.net/

Linux Sendmail Configuration: Configure a Linux eMail Server http://www.yolinux.com/TUTORIALS/Sendmail.html


Lightweight outgoing SMTP server https://unix.stackexchange.com/questions/1449/lightweight-outgoing-smtp-server