"Linux Gazette...making Linux just a little more fun!"

The Answer Guy

By James T. Dennis, tag@lists.linuxgazette.net
Starshine Technical Services, http://www.starshine.org/

(?)'sendmail' FEATURE creatures for virtual domain and generic re-write tables

From Benjamin Peikes on 18 May 1998


I have a quick sendmail question for you. I have set up virtual hosting where I add an account for each user and then map the incoming and outgoing address for each account. The problem is that I add an account, i.e. bendtg and then map outgoing mail to be ben@dtgroup.com and mail incoming mail for ben@dtgroup.com to go to the bendtg account. The problem is that I will also get mail going to bendtg@anyotherhostI.receive.mail.for. I was wondering if you knew what I need to set so that it only accepts mail for a particular list of addresses that I specify. Thanks alot.


(!) I thought I answered this for you earlier this month. Is this a resend --- or a refinement to an earlier question?

[Nope, he's only got the one, but we do have a lot of sendmail questions this month. -- Heather]

In any event the FEATURE's that you might want to enable and use in your 'sendmail' "mc" (M4 configuration file) are the "virtusertable", and the "genericstable"

These can allow you to support the re-writing of addresses in outgoing mail, and to support things like matching a whole domain to a single mbox (mailbox folder) file. You can also creating entries in the virtusertable that look just like aliases --- except that they include host/domain portions of addresses (parts to the right of the "@" (at) sign).

Unfortunately I don't have working samples of these files but the M4/mc file would look something like:
VERSIONID(`@(#)YOURDOMAINHERE.mc	.1 (BP) 8/11/95')
And you'll have to create these tables (usually as dbm files) You can read more about these advanced sendmail features in the famous "Bat Book" (Sendmail 2nd edition by Bryan Costales, from O'Reilly & Associates).

After you've merged some of these features into your mc file you'll build a sendmail.cf file by running m4 on it (I'd usually do an RCS check ('ci -l') of my old /etc/sendmail.cf file before overwriting it with the new one -- and I keep my mc files under version control as well).

Once you've created the sendmail.cf file (and tested that it hasn't broken any of the feature you were already using) you need to create one or more tables (depending on which combination of 'genericstable', 'virtusertable', and 'domaintable' (and other features/tables you choose to use). These are created with a text editor and must be "compiled" or "made" into a suitable format (usually some dbm variant) using the 'makemap' command.

The Costales book goes into that in some detail -- but the thing is 800 pages long and it's easy to get lost in that tome. So you might want to just read the 'makemap' man page.

Basically all this 'makemap' stuff is just like running 'newaliases' after you change the /etc/aliases file. It's even possible to force sendmail to use a straight text file for a table if you want to (but that's hackish and definitely more trouble than its worth.

I have another problem with this whole approach. If you are mapping all of the mail to a given domain or for a given host into a single "drop file" (mbox folder) which some user is getting (say, via POP or IMAP --- perhaps using Eric Raymond's 'fetchmail' package) your customers still have a problem if they then need to split the mail into multiple addresses at their site.

I've been told by one of Netcom's senior techs that they resolve this with a custom re-writing rule that take the envelope addressee(s) (the address or list of addresses as it was passed to the receiving sendmail daemon) and add those as Bcc: header lines before putting the message in the drop file.

(The effect of this is that if a piece of mail was addressed to you, and copied to some partner at your site --- the receiving 'fetchmail' process should process those Bcc: lines --- as appropriate to your domain).

I haven't confirmed this, nor have a concocted a custom FEATURE macro (m4) or rewriting ruleset to do this --- though I'd like to see one and play with it.

My personal opinion is that all this virtual mail domain to "drop file" stuff is ugly and hackish --- so I still use a uucp feed to get mail from my ISP to my domain and back (and I use it to get my netnews, too).

As always the best sources of sendmail support on the 'net are:
NetNews: comp.mail.sendmail
The FAQ (web version):
comp.mail.sendmail Frequently Asked Questions (Part 1 of 2)
http://www.cis.ohio-state.edu/hypertext/faq/usenet/mail/sendmail-faq/part1/faq.html -- You want Q3.7: How do I manage several (virtual) domains?
Other Web Resources:
Harker Systems:
(Offers wonderful and very detailed seminars on 'sendmail' and DNS. I've taken it --- and only wish that I'd had the time to apply even a fraction of that in my consulting over the last several months. I've Bcc'd him on this message as a courtesy).

Copyright © 1998, James T. Dennis
Published in Linux Gazette Issue 29 June 1998

[ Answer Guy Index ]
versions lilo virtdom kernel winmodem basicmail betterbak
shadow dell dumbterm whylinux redhat netcard macrovir
newlook tacacs sendmail dialdppp ppp233 msmail procmail

[ Table Of Contents ] [ Front Page ] [ Previous Section ] [ Next Section ]