Sendmail: send-only when local system has no domain name
Tags domain name, hostname, sendmail
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
Process the new .mc file into sendmail's configuration file, /etc/mail/sendmail.cf (may vary according to distro):
Create the authinfo file, readable only by root, containing
and process it int a .db file for sendmail to use:
and re-initialise sendmail, for example (varies according to distro) by:
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:
and process it int a .db file for sendmail to use:
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
to
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
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')
Code:
root:/usr/share/sendmail/cf/cf# m4 sendmail-slackware.CW8.02.mc > /etc/mail/sendmail.cf
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"
Code:
root:/etc/mail# makemap hash authinfo < authinfo
Code:
/etc/rc.d/rc.sendmail restart
Code:
root:<email address for root mail to be forwarded to>
Code:
root:/etc/mail# newaliases
Code:
<your IP address> <your hostname>.localdomain <your hostname>
Code:
<your IP address> <your hostname>
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
Total Comments 0