LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Blogs > catkin
User Name
Password

Notices

Rate this Entry

Sendmail: send-only when local system has no domain name

Posted 10-13-2009 at 01:04 PM by catkin
Updated 10-18-2009 at 12:31 PM by catkin

Hello

EDIT: this works but causes sendmail to pause for ~1 minute when it can't find its own FQDN; this slows boot (if sendmail is started at boot and not backgrounded) and would be un-workable on a busy mail server.

Here's how to configure sendmail to send mails when the computer is configured with a hostname but no domain name. It may be of use, for example, if you want to mail system exception reports and do not want to configure the computer as being part of a domain.

The issue is that most mail receiving servers will not accept mail that does not come from a valid domain. The usual workaround is to configure the local machine with a domain name but for the purists that may not be acceptable.

Almost all the information is available on the Internet but it took me a long time to piece it all together, hence publishing this blog entry in case somebody else (another mad purist!) wants to do the same thing.

Modify sendmail's .mc file, adding the following lines. On Slackware 13.0, this file is /usr/share/sendmail/cf/cf/sendmail-slackware.mc. It is prudent to make a copy; in this example it was copied to sendmail-slackware.CW8.2.mc and modified as shown by this diff output
Code:
c:/usr/share/sendmail/cf/cf$ diff sendmail-slackware.mc sendmail-slackware.CW8.2.mc
0a1
> dnl#@ Local changes identified by comment introducer dnl#@
13c14,15
< VERSIONID(`default setup for Slackware Linux')dnl
---
> dnl#@ VERSIONID(`default setup for Slackware Linux')dnl
> VERSIONID(`CW8 version 2')dnl
21a24,25
> dnl#@
> define(`SMART_HOST',`<your mail service provider's SMTP server name>')
34a39,44
> dnl#@
> FEATURE(authinfo)
> FEATURE(delay_checks)dnl
> FEATURE(masquerade_envelope)dnl
> FEATURE(allmasquerade)dnl
> FEATURE(masquerade_entire_domain)dnl
42a53,57
> dnl#@
> MASQUERADE_AS(`<your legitimate domain name>')dnl
>
> DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
Process the new .mc file into sendmail's configuration file, /etc/mail/sendmail.cf (may vary according to distro):
Code:
root:/usr/share/sendmail/cf/cf# m4 sendmail-slackware.CW8.02.mc > /etc/mail/sendmail.cf
Create the authinfo file, readable only by root, containing
Code:
AuthInfo: "U:<logon name for your mail service provider's SMTP server>" "P:<password or your mail service provider's SMTP server>" "M:PLAIN"
and process it int a .db file for sendmail to use:
Code:
root:/etc/mail# makemap hash authinfo < authinfo
and re-initialise sendmail, for example (varies according to distro) by:
Code:
/etc/rc.d/rc.sendmail restart
Those are the essentials. If you want mail sent to root on the local machine to be forwarded to a remote email recipient, create or edit /etc/mail/aliases:
Code:
root:<email address for root mail to be forwarded to>
and process it int a .db file for sendmail to use:
Code:
root:/etc/mail# newaliases
If you have a <hostname>.localdomain entry in /etc/hosts the mail will be received as being sent to root@<hostname>.localdomain. If you prefer it to appear as sent to root@<hostname> then modify /etc/hosts, changing
Code:
<your IP address> <your hostname>.localdomain <your hostname>
to
Code:
<your IP address> <your hostname>
This last change upsets sendmail which really, really wants to know what its fully qualified domain name is and sleeps for a while before re-trying in case it can find out later. Eventually it gives up and settles for the host name only but this slows boot drastically. The workaround is to modify the boot script that starts sendmail so it backgrounds sendmail startup.

That's it! Any mail sent to root locally will now be forwarded to <email address for root mail to be forwarded to> where it will appear as being sent to root@<your hostname>.

This method developed and tested on Slackware 13.0 running sendmail 8.14.3.

Best

Charles
Posted in Uncategorized
Views 6795 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 08:58 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration