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=,, 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 &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  $4
R$* $| $*                      $: $2

by


# pass to name server to make hostname canonical
R$* $| $*  $*           $: $2  $4
R$* $| $*                       $: $2

Be VERY carreful with the tabulations!

Just relaunch sendmail

svcadm refresh network/smtp:sendmail

And test again …

This entry was posted in Linux, Solaris and tagged , , , , , , , , , , , , . Bookmark the permalink.

2 Responses to Setup Sendmail without DNS

  1. Marko Hrastovec says:

    Hi,

    I am having a similar configuration. However, my sendmail has access to DNS except this DNS is internal and does not have access to outside world. It resolves only some special local domains. Of course it resolve the smarthost too. In my case sendmail did not want to relay because it was not able to resolve recipients addresses. In that case I made only few things from the list above:

    sendmail.mc:
    define(`SMART_HOST’,`mail’)
    FEATURE(nocanonify)

    submit.mc:
    define(`confDIRECT_SUBMISSION_MODIFIERS’, `C’)dnl

    Then make and restart sendmail and it works. Now it relays to a smarthost which has regular DNS and access to internet. I am using CentOS 5 and sendmail that comes with it.

  2. zeve says:

    Many thanks,

    I googled on Friday for 3 hours and tried a bunch of stuff until I stumbled on you blog. Nice small “How To”.

    PS: you should also add a “relay” keyword somewhere, makes it easier to find it.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Vous pouvez utiliser ces balises et attributs HTML : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>