*BSD News Article 47031


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!news.sprintlink.net!dnaco.net!portia!usenet
From: marnellm@kimble.portia.com (Matthew Marnell)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Mail to info@d1.com and info@d2.com: different users on same host: Possible?
Date: 17 Jul 1995 04:27:32 GMT
Organization: Portia Communication & Internet Services
Lines: 135
Message-ID: <MARNELLM.95Jul16212733@kimble.portia.com>
References: <betts.47.03608E4B@onramp.net> <3tqnbg$bv9@bonnie.tcd-dresden.de>
NNTP-Posting-Host: kimble.portia.com
In-reply-to: j@bonnie.heep.sax.de's message of 10 Jul 1995 10:11:28 +0200
Bcc: marnellm@portia.com

In article <3tqnbg$bv9@bonnie.tcd-dresden.de> j@bonnie.heep.sax.de (J Wunsch) writes:

> Jeff Betts <betts@onramp.net> wrote:
> 
> >What I NEED is a way to have mail for info@d1.com and info@d2.com
> >delivered to different users (or even just different POP mailboxes, but
> >that doesn't look likely either).
> 
> Sendmail has not been designed for such.  The only chance would be to
> run all mail for `info' through a filter that's selecting based on the
> To: address.  This assumes d1.com and d2.com are not CNAME aliases,
> since sendmails usually canonicalize alias addresses.

Using sendmail's built in database support this should be doable.  As
a matter of fact, it is built in.  Let me just go rumage through my
archives, although doing this without O'Reilly's 'sendmail' book is
not for the faint of heart.

<quoted article>

I've (not me) moved this from ruleset S98 to ruleset S96 so that I don't
have to add "Cw" lines for each domain, and simplified things.

   In addition to the "K" line defining the maildomains file,
   add only these two lines:

      R$+ < @ $+ > $*           $: $(maildomains $1@$2 $: $1 < @ $2 > $3 $)
      R$+ < @ $+ > $*           $: $(maildomains $2 $: $1 < @ $2 > $3 $)

   Just before these lines:

      # pass to name server to make hostname canonical
      R$* < @ $* $~P > $*               $: $1 < @ $[ $2 $3 $] > $4

   in ruleset S96.

<end of quoted article>

<a related quoted article>

I forgot to mention that the format of the "maildomains" file
changes slightly due to moving to ruleset S96.  When the
destination address is at a different site (right-hand-side of
the database entry in maildomains contains a '@'), it should
now look like this:


bob@domain.com               george<@netcom.com>
domain.com                   harry<@somewhere.net>

also, be sure to use tab characters.

<end of the related quoted article>

<yet another article>

If you have procmail installed

create a user account called info

.procmailrc

:0
* ^To.*domaina.com*
! infoa

:0
* ^To.*domainb.com*
! infob

<end of yet another article>

<And the response to said article>

This doesn't work if you're cc'd on a message, or bcc'd, or receiving it
via a mailing list, or the sender has a private alias for you.  By the time
the message reaches procmail, the envelope recipient address is lost, and
that's the only thing you can trust.  The only global solution for this,
for sendmail 8, is Vixie's.

IDA sendmail allowed non-local aliases in the aliases file, so you really
could have

info%domain1@localhost  : user1
info%domain2@localhost  : user2

As long as neither domain1 nor domain2 evaluated to the local mailer.  (The
@localhost was a necessary hack.)  Does sendmail 8 allow this?  It was
mainly useful for forcing local delivery even on a host where (normally)
all local mail was forwarded to a mailserver.

<end>

<and my last quoted article regarding this question>

I use the db functions of sendmail for faster lookups, and non-local mail
delivery.

Add this line near the top of your sendmail.cf:

Kmaildomains btree /etc/maildomains.db

(this is assuming you're using btree.. I'm using BSD's db libraries)

Add the following rules to S98:

R$+ < @ $+  . >         $: $1 < @ $2 > .
R$+ < @ $+ > $*         $: $(maildomains $1@$2 $: $1 < @ $2 > $3 $)
R$+ < @ $+ > $*         $: $(maildomains $2 $: $1 < @ $2 > $3 $)
R$+ < @ $* > .          $: $1 < @ $2 . >

Create the a file with the following format: (I call mine /etc/maildomains)

joe@abc.com             joe
jane@abc.com            jane
info@abc.com            info-abc
abc.com                 mark            <-  the default case.

Run the following command:

makemap btree maildomains <maildomains

(once again, assuming you're using btree databases)

<end again>

There are many ways to do this with sendmail, smail, IDA, procmail.  I
prefer the maildomains approach with sendmail.  Dang, for something
that wasn't design for that, it sure has some built in abilities, No?

Matt Marnell

(These quotes are from my cohorts on inet-access and bsdi-users
mailing lists, credit should go where credit is due, I didn't come up
with these approachs, just cut and pasted them for later reference.)