Sendmail on RHEL 4.0 - Without DNS
// March 20th, 2007 // Unix, Work
For any of you who have ever tried to use or configure sendmail, you know it’s not a fun task. At best, you wince, try to browse some google groups as you make your way through the billions of posts regarding some tribal knowledge that has to do with this release of sendmail on that specific OS. Then throw DNS into the mix, sendmail’s partner in crime and we’ve got a real ho-down. Especially when DNS goes missing. When DNS doesn’t arrive for the party, sendmail gets mad.
Real mad.
Anyways, in alot of our networks, we have hosts that don’t have DNS. Why? Because we’re too lazy to set the shit up. Seriously tho, it’s mostly because work has me stuck on building machines ( ie: monkey work ) rather than trying to solve the real issues in our infrastructure. Since I just spent the last hour trying to figure out how to get a RedHat Enterprise 4 ( U4 ) machine to send mail without DNS to a smart relay host, I thought I’d share the results and how to do it.
First, make sure you have the sendmail-cf package installed. Either install it locally via media or use yum/up2date to get it.
rpm -ivh sendmail-cf-8.13.1-3.RHEL4.5.i386.rpm
Next, add your smart relay host to your /etc/hosts file
192.168.0.6 mailhost mailhost.domain.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',`mailhost')
Note: The first character after the “FEATURE(” is a tick mark ( ` ) from the tilde key, this is not a typo. The ending quotation is a single quote mark ( ‘ ). I’ve enclosed the code in pre tags, although it looks ugly, to ease copying and pasting into the configuration. Please look at the sendmail.mc file for more clarification.
Of course, replace the mailhost with the host you entered in your /etc/hosts file. Now create a file in /etc/mail called service.switch and add the following:
hosts files
For our last file modification, 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. You shouldn’t see any output, but if you do a directory listing, you should see some .bak files now. You can compare these with the current .cf files to see what changes were made.
Restart sendmail and the sm-client:
service sendmail restart
And voila! You should now successfully be able to send mail to your smart relay host with no DNS. To test, trying something like this:
mail -s test name@domain.com < /dev/null 2>&1 >> /dev/null
Cross your fingers, sacrifice a few goats and chickens, do a little dance, make a little love and check your inbox for the test email.










Steve, it sure seems like a lot of work,
Just use hotmail, it works every time, haha!
post the conf!!!
This really works.Thanks pal it is very useful.If anyone tries to copy and paste the configs from this tutorial please take a note that the ‘ sign is pasted like . and may be thats the problem for the tutorial not working.So if you are useing Putty or other ssh client please be sure that the pasted text is exactly like this one otherwise wont work.Once again thanks man for this great how to.
Thanks beji. I’m glad you’ve found it helpful. I’ve made a note in the document to try and clarify the situation that m4 uses a tick mark and a single quotation.
Great tutorial! Now also my sendmail seems to work.
I applied this guide on an old red hat 9 with sendmail 8.12.8
Thanks a lot.
HI,
Thanks a lot. This really works.
Regards
Very helpful, thanks for posting this! Aleksey.
Great article, and this is what I was looking for, but I am using CentOS 5 and I get this error:
[root@localhost mail]# mail -s test root@domain.com &1 >> /dev/null
in /var/log/maillog:
Jul 20 12:13:24 localhost sendmail[3068]: m6KADO1c003068: from=root, size=35, class=0, nrcpts=1, msgid=, relay=root@localhost
Jul 20 12:13:24 localhost sendmail[3069]: m6KADONS003069: from=, size=330, class=0, nrcpts=1, msgid=, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Jul 20 12:13:24 localhost sendmail[3068]: m6KADO1c003068: to=root@domain.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30035, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (m6KADONS003069 Message accepted for delivery)
Jul 20 12:13:24 localhost sendmail[3071]: m6KADONS003069: to=, ctladdr= (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=120330, relay=mailhost [192.168.1.20], dsn=4.0.0, stat=Deferred: Connection refused by mailhost
I do a telnet:
[root@localhost mail]# telnet mailhost 110
Trying 192.168.1.20…
Connected to mailhost.domain.com (192.168.1.20).
Escape character is ‘^]’.
+OK Dovecot ready.
Dovecot is working.
Any clues about what could be wrong?
Marco,
Have you tried telnetting to port 25 on 192.168.1.20? I believe 110 is for POP3, not for sending email. It looks like you successfully sent to your local submit queue, which then gives it off to sendmail to send and it’s having trouble contacting the mailhost 192.168.1.20 on port 25 for some reason.
What I am trying to do is to send a mail from one server to another without DNS. I have sendmail and dovecot in both servers. Shouldn’t dovecot accept mails on port 110? Why the telnet to port 25?
thanks for this! I searched the net and tried for around 2 hours now, but your guide made it finally working
thanks
@marco: 110 is the pop3 port. your server does normally not accept any mails there, but you can connect there and receive mails.
if a mail should get sent to this server he is normally listening on port 25 which is smtp
thanks it helped me!!
i guess in submit.mc file should look like this
FEATURE(`msp’, `[your.outgoingserver.com]‘)dnl
define(`confDIRECT_SUBMISSION_MODIFIERS’, `C’)dnl