Setup Sendmail without DNS

Configure Sendmail is not very funny.
In my case I have several box in a DMZ and i would like these box will be available to send email from my mail server. But sendmail need a valid MX reply to relay emails.
Without this valid MX you should have this error in the log file

Apr 4 15:46:32 SERVER-01 sendmail[2422]: [ID 801593 mail.info] m34DdKJC002400: to=<evargas@mycompany.com>,<hello@SERVER-01.internaldomain.fr>, delay=00:07:12, xdelay=00:00:00, mailer=relay, pri=240354, relay=mail, dsn=4.0.0, stat=Deferred: Name server: mailhost: host name lookup failure

When DNS doesn’t arrive for the party, sendmail gets mad.

How to solve this?

Linux (Redhat, Fedora, Debian)
First make sure you have the sendmail-cf package installed. Either install it and use yum/up2date/apt-get to get it.

rpm -Uvh sendmail-cf-8.13.1-3.fc2.i386.rpm

Next, add your smart relay host to your /etc/hosts file (your mail server)

192.168.1.100 mail mail.yourdomain.com

Go into /etc/mail/ and vi the sendmail.mc file. Add the following lines:

FEATURE(`accept_unresolvable_domains')dnl
FEATURE(`accept_unqualified_senders')dnl
FEATURE(nocanonify)
define(`confSERVICE_SWITCH_FILE', `/etc/mail/service.switch')dnl
define(`SMART_HOST',`mail')

Of course, replace the mail with the host you entered in your /etc/hosts file.
Now create a file in /etc/mail called service.switch and add the following:

root@SERVER-01 # cat /etc/mail/service.switch
hosts files
root@SERVER-01 #

Edit the submit.mc file in /etc/mail and add the following line:

define(`confDIRECT_SUBMISSION_MODIFIERS', `C')dnl

Now that we’re done making our file modifications, simply type make while in the /etc/mail directory.

Restart sendmail

/etc/init.d/sendmail restart

That’s it!

just need to test it:

mail -s test toto@mydomain.com < /dev/null 2>&1 >> /dev/null

Solaris

More easy on solaris 10 (same thing on V8 and V9)
Edit the files /etc/mail/sendmail.cf and /etc/mail/submit.cf
and uncomment the following lines:

# service switch file (name hardwired on Solaris, Ultrix, OSF/1, others)
O ServiceSwitchFile=/etc/mail/service.switch

# hosts file (normally /etc/hosts)
O HostsFile=/etc/hosts
root@SERVER-01 # more service.switch
hosts files

don’t forget to setup your host file


127.0.0.1       localhost       SERVER-01.mydomain.com
192.168.1.100    mail    mail.mydomain.com

Check in your /etc/nsswitch.conf file the line “hosts” like this:


hosts:      files

Check in your sendmail conf file (main.cf, sendmail.cf, subsidiary.cf) your relay host is setup


# "Smart" relay host (may be null)
DSmail

In the same files replace the following lines


# pass to name server to make hostname canonical
R$* $| $* < @ $* > $*          $: $2 < @ $[ $3 $] > $4
R$* $| $*                      $: $2

by


# pass to name server to make hostname canonical
R$* $| $* < @ $* > $*           $: $2 < @ $3 > $4
R$* $| $*                       $: $2

Be VERY carreful with the tabulations!

Just relaunch sendmail

svcadm refresh network/smtp:sendmail

And test again …

Leave a Reply