this is obsolete doc -- see http://doc.nethence.com/ instead

Configuring Sendmail as an SMTP client 

 

Adding a smart host 

Using the M4 macros 

On Slackware Linux, 

cd /usr/share/sendmail/cf/cf/
grep -v ^dnl sendmail-slackware.mc > sendmail.mc
vi sendmail.mc

add (before MAILER), 

define(`SMART_HOST', `smtp.free.fr')

eventually masquerade the host and domain name if using a non-resolvable TLD (also before MAILER), 

MASQUERADE_AS(example.net)dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(host.example.net)dnl

note. Change the host and domain name accordingly. 

remove, 

EXPOSED_USER(`root')dnl

and apply, 

ls -l ../m4/cf.m4
mv -i /etc/mail/sendmail.cf /etc/mail/sendmail.cf.old
m4 sendmail.mc > /etc/mail/sendmail.cf
/etc/rc.d/rc.sendmail restart
echo test | mail -s test root
mailq -Ac
mailq

note. I am assuming root is a alias to a real address, already. 

 

On RHEL, 

rpm -q sendmail sendmail-cf m4
cd /etc/mail/
cp sendmail.mc sendmail.mc.dist
cp submit.mc submit.mc.dist

USE THE M4 CONFIGURATION FROM SLACKWARE (just change the include), the Red Hat one didn't work here for masquerading, 

#grep -v ^dnl sendmail.mc.dist > sendmail.mc
#egrep -v '^dnl|^#|^$' submit.mc.dist > submit.mc
rm -f sendmail.mc
cat sendmail.mc <<EOF9
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
VERSIONID(`default setup for Slackware Linux')dnl
OSTYPE(`linux')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confTO_IDENT', `0')dnl
FEATURE(`use_cw_file')dnl
FEATURE(`use_ct_file')dnl
FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl
FEATURE(`access_db', `hash -T<TMPF> /etc/mail/access')dnl
FEATURE(`blacklist_recipients')dnl
FEATURE(`local_procmail',`',`procmail -t -Y -a $h -d $u')dnl
FEATURE(`always_add_domain')dnl
FEATURE(`redirect')dnl
LOCAL_DOMAIN(`localhost.localdomain')dnl
define(`SMART_HOST', `smtp.free.fr')
MASQUERADE_AS(example.net)dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(host.example.net)dnl
MAILER(local)dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
EOF9

apply (the m4 macros are applied and sendmail.cf gets regenerated automaticly on RHEL), 

ls -l sendmail.cf submit.cf
service sendmail restart
ls -l sendmail.cf submit.cf
#vi /etc/aliases
#newaliases
echo | mail -s test root
mailq -Ac
mailq

 

Editing the sendmail configuration file directly 

On Slackware (not sure it's possible on RHEL to edit this directly), 

cd /etc/mail/
cp sendmail.cf sendmail.cf.dist
#redhat also cp submit.cf submit.cf.dist
vi sendmail.cf
#redhat also vi submit.cf

change, 

  DSsmtp.free.fr 

and force an alternate hostname when talking to remote smtp hosts, 

  DMexample.net 

  #Djhost.example.net 

apply, 

/etc/rc.d/rc.sendmail restart
#redhat: /etc/rc.d/init.d/sendmail restart
echo | mail -s test root

 

On NetBSD this also seemed to work, 

define(`SMART_HOST', `YOUR_ISP_SMTP')dnl
FEATURE(`msp', `smart_host')dnl

Note. if you want to use an IP instead, add brackets e.g., 

define(`SMART_HOST', `[xx.xx.xx.xx]')dnl

 

Usage and administration 

Show the MTA queue, 

mailq

 

Show the mail submission queue, 

mailq -Ac

 

Additional notes 

Generally, macros are configured like this with the M4 macros, 

define(`confMILTER_MACROS_CONNECT', `j, _, {daemon_name}, {if_name}, {if_addr}')dnl

 

Troubleshooting 

X-Authentication-Warning 

If you want to get rid of those warning logs, add the user to sendmail's trusted users. Check sendmail's configuration, 

ls -l /etc/mail/
grep trusted /etc/mail/sendmail.cf
(it should retyurn "Ft/etc/mail/trusted-users")

then, 

ls -l /etc/mail/trusted-users
echo username >> /etc/mail/trusted-users

 

Otherwise force the trusted users within sendmail.cf manually e.g., 

Tusername

or using the M4 macros, 

FEATURE(use_ct_file)dnl

 

Sender address rejected: Domain not found 

If the MAILER-DAEMON on the smart host or the destination host says, 

550 5.1.8 <...>: Sender address rejected: Domain not found
554 5.0.0 Service unavailable

then masquerade your host and domaine name (see the first paragraph on this page). 

 

References 

smart host 

http://www.dawoodfall.net/index.php/configuring-sendmail/9-configuring-and-building-sendmail-config-files-in-slackware 

/usr/share/sendmail/cf/cf/sendmail-slackware.mc 

/usr/share/sendmail/cf/README 

/usr/share/sendmail/cf/README.linux 

/usr/share/sendmail/README.linux 

http://www.akadia.com/services/sendmail_relay.html 

 

rhel 

https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-email-mta-sendmail.html 

 

masquerade 

http://www.zoxx.net/notes/index.php/post/2007/04/27/37-configurer-sendmail-comme-simple-relai-vers-un-autre-serveur-email 

http://www.cyberciti.biz/tips/sendmail-masquerading-configuration-howto.html 

http://www.sendmail.com/sm/open_source/docs/m4/masquerading.html 

 

misc 

http://www.sendmail.org/~ca/email/sm-812.html 

Restricting users : http://www.sendmail.org/~ca/email/restrict.html