Visit Jeremy's Blog.
Go Back > Blogs > catkin
User Name


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


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/ It is prudent to make a copy; in this example it was copied to and modified as shown by this diff output
c:/usr/share/sendmail/cf/cf$ diff
> dnl#@ Local changes identified by comment introducer dnl#@
< VERSIONID(`default setup for Slackware Linux')dnl
> dnl#@ VERSIONID(`default setup for Slackware Linux')dnl
> VERSIONID(`CW8 version 2')dnl
> dnl#@
> define(`SMART_HOST',`<your mail service provider's SMTP server name>')
> dnl#@
> FEATURE(authinfo)
> FEATURE(delay_checks)dnl
> FEATURE(masquerade_envelope)dnl
> FEATURE(allmasquerade)dnl
> FEATURE(masquerade_entire_domain)dnl
> dnl#@
> MASQUERADE_AS(`<your legitimate domain name>')dnl
> DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')
Process the new .mc file into sendmail's configuration file, /etc/mail/ (may vary according to distro):
root:/usr/share/sendmail/cf/cf# m4 > /etc/mail/
Create the authinfo file, readable only by root, containing
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:
root:/etc/mail# makemap hash authinfo < authinfo
and re-initialise sendmail, for example (varies according to distro) by:
/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:
root:<email address for root mail to be forwarded to>
and process it int a .db file for sendmail to use:
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
<your IP address> <your hostname>.localdomain <your hostname>
<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.


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




All times are GMT -5. The time now is 04:14 AM.

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