procmail
[Top] [All Lists]

Re: Bcc addresses

1997-02-07 16:50:54


On Fri, 7 Feb 1997, Dorita Menconi wrote:

is it a sendmail question?

It is a sendmail question.

The unfortunate fact that there is not a simple
sendmail answer is often discussed on this mailing
list.  Even though many people on the procmail list
are upset by discussion of this topic, the truth is
that it is a very desirable function/feature, given
the number of people who want to do this. 

I submit that it is of interest to Procmail users,
regardless of what is thought of that by people
who do not need this interface.

I suggest there is a niche here, for someone to 
either make some money or win some popularity by
solving this problem once and for all.

Philip G. came close, by giving the theory and certain
examples of how it COULD be done.  I worked out some things
specific to my network based on that advice, but nobody
from the list actually followed through with a fully 
presentable solution.  Not that anyone was expected to,
just that the question remains as to the correct way to do 
this.

I attached a message to this, however, that is the closest thing
so far to a solution.  

--
g-r-a-t-e-f-u-l-l-y---[   email:<fishbowl(_at_)conservatory(_dot_)com>   
]---l-i-v-i-n-g
d-e-a-d-i-c-a-t-e-d---[ http://www.conservatory.com/~fishbowl ]-----l-i-g-h-t
Loan-department manager:  "There isn't any fine print.  At these
interest rates, we don't need it."
From POPmail Tue Dec  3 23:17:33 1996
X-POP3-Rcpt: fishbowl(_at_)www
Return-Path: procmail-request(_at_)Informatik(_dot_)RWTH-Aachen(_dot_)DE
Received: from Campino.Informatik.RWTH-Aachen.DE 
(campino.Informatik.RWTH-Aachen.DE [137.226.116.240]) by netcomi.com 
(8.7.5/8.7.3) with ESMTP id XAA23695 for <fishbowl(_at_)netcomi(_dot_)com>; 
Tue, 3 Dec 1996 23:20:50 -0600
Received: (from lists(_at_)localhost) by Campino.Informatik.RWTH-Aachen.DE 
(RBI-Z-5/8.6.12) id FAA17645 for fishbowl(_at_)netcomi(_dot_)com; Wed, 4 Dec 
1996 05:19:02 +0100 (MET)
Resent-Date: Wed, 4 Dec 1996 05:19:02 +0100 (MET)
X-Authentication-Warning: campino.informatik.rwth-aachen.de: lists set sender 
to procmail-request(_at_)informatik(_dot_)rwth-aachen(_dot_)de using -f
From: "Dan T." <dragon(_at_)dragon(_dot_)cyberhighway(_dot_)net>
Message-Id: 
<199612040503(_dot_)WAA04903(_at_)dragon(_dot_)cyberhighway(_dot_)net>
Subject: Ans:  Virtual Domain's using procmail
To: procmail(_at_)Informatik(_dot_)RWTH-Aachen(_dot_)DE
Date: Tue, 3 Dec 1996 22:03:25 -0700 (MST)
X-Mailer: ELM [version 2.4 PL24]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Resent-Message-ID: <"jt1SSD.A.LOE.rgPpy"@campino>
Resent-From: procmail(_at_)Informatik(_dot_)RWTH-Aachen(_dot_)DE
X-Mailing-List: <procmail(_at_)informatik(_dot_)rwth-aachen(_dot_)de> 
archive/latest/8634
X-Loop: procmail(_at_)informatik(_dot_)rwth-aachen(_dot_)de
Precedence: list
Resent-Sender: procmail-request(_at_)Informatik(_dot_)RWTH-Aachen(_dot_)DE
Status: RO
X-Status: 



There have been many questions about using procmail for Virtual Domain's.
I was one of the people that asked, and was always told that "procmail
is not the answer, it is a sendmail thing".

I did have to use some new sendmail features, but as it is asked often
enough I figured I'd post my solution (and I promised several people I 
would).  I'm not an expert (although I'm learning fast), so if there are
any sendmail guru's reading this, I don't mind critisism :)

I wanted procmail to do it rather then sendmail for a couple reasons:

  1)  I want the user to be able to directly edit thier Virtual Domain
      email config file.  Using procmail, they have "real time" access
      to thier .procmailrc file.  All setup is done in the owners home
      directory.

  2)  I want the user to be able to set up thier own utilities.  Such as
      auto-responders, users, lists, whatever.  I have over 300 domains
      and REALLY don't want to administer them all.  BTW  I've had NO
      complaints since I set this up.

This is a long post, so hear goes:

SENDMAIL:

  1)  I'm using sendmail 8.8.x, but I'm sure 8.7.x will work.  Also, I use
      the m4 macro files to generate my sendmail.cf, so that is how
      I'm going to explain these.

  2)  Unless someone knows how to change it in the .mc file, I modified
      the cf/mailer/procmail.m4 file.  You have to remove the 'm' in the
      PROCMAIL_MAILER_FLAGS.  For example it should just say:

        `define(`PROCMAIL_MAILER_FLAGS', `Shu')')

      The reason this is done, is so you will receive one email for
      each recipient the email is addressed to.  I havn't found a way
      to get sendmail to pass multiple recipients to procmail.

  3)  In your host.mc file (or whatever you call it), enable "local_procmail"
      "procmail mailer", and "mailertables".  For example:

        -----------------------------start---------------------------------
        VERSIONID(`@(#)generic-hpux9.mc 8.2 (Berkeley) 8/6/95')
        OSTYPE(hpux10)dnl
        FEATURE(local_procmail)dnl
        FEATURE(mailertable, btree /etc/mail/lib/mailertable.db)dnl
        MAILER(procmail)dnl
        MAILER(local)dnl
        MAILER(smtp)dnl
        ------------------------------end----------------------------------

      To compile use:        m4 ../m4/cf.m4 host.mc > host.cf

      This will create a sendmail.cf file that has all the stuff you need.

  4)  In the file /etc/mail/lib/mailertable add one line for each of
      your virtual domains.  For example:

        -----------------------------start---------------------------------
        domain1.com     procmail:/etc/mail/Ehosts/rc.domain1.com
        domain2.com     procmail:/etc/mail/Ehosts/rc.domain2.com
        domain3.com     procmail:/etc/mail/Ehosts/rc.domain3.com
        domain4.com     procmail:/etc/mail/Ehosts/rc.domain4.com
        domain5.com     procmail:/etc/mail/Ehosts/rc.domain5.com
        ------------------------------end----------------------------------

      To compile use:        makemap btree mailertable < mailertable

      That is a <tab> before "procmail..." not spaces.  Now is where you
      have control of your domain with procmail.

PROCMAIL:

  1)  For each domain, create an "rc" file for them defining specific info
      about that domain.  For example:

        -----------------------------start---------------------------------
        OWNER=someuser(_at_)RealDomain(_dot_)net
        DOMAIN=domain1.com
        LIBDIR=/etc/mail/rc.d
        INCLUDERC=$LIBDIR/rc.ehosts
        ------------------------------end----------------------------------

      Then in the "rc.ehosts" file use something like:

        -----------------------------start---------------------------------
        ADMIN=postmaster(_at_)RealDomain(_dot_)net         # Your E-mail admin
        MAILDIR=/etc/mail
        LIBDIR=${MAILDIR}/rc.d
        SHELL=/bin/sh                           # Avoid surprises
        PATH=/bin:/usr/bin:/usr/local/bin:${MAILDIR}/bin
        COMSAT=no                               # Don't notify Comsat
        ENVELOPE_FROM=$1                        # Envelope sender
        ENVELOPE_TO=$2                          # Envelope recipient

        ### This creates a header "X-Envelope-To" containing the original
        ### recipient of the message.  This works even if the recipient
        ### is a Bcc'd address!!!  And since we took the 'm' out of
        ### the procmail flags in the sendmail.cf, it also works for
        ### multiple recipients.
        :0 fhw
        | formail -I"X-Envelope-To:  $ENVELOPE_TO"

        ### I filter all mail sent to "abuse" so I can catch spammers
        :0
        * $ ENVELOPE_TO ?? abuse@"$DOMAIN"
        ! -f $ENVELOPE_FROM $ADMIN

        ### I filter all mail sent to "postmaster" in case there is a 
        ### problem that only I can fix.
        :0
        * $ ENVELOPE_TO ?? postmaster@"$DOMAIN"
        ! -f $ENVELOPE_FROM $ADMIN

        ### Send all messages to the appropriate owner.
        :0
        ! -f $ENVELOPE_FROM $OWNER
        ------------------------------end----------------------------------

      All control is now passwd to the users .procmailrc file, AND with the
      "X-Envelope-To" header, they can route the email properly without 
      losing Bcc'd mail and multiple recipients.

  2)  Setup the users .procmailrc file.  Here is my default:

        ~/.procmailrc
        -----------------------------start---------------------------------
        PATH=/bin:/usr/bin:/usr/local/bin:$HOME/bin
        MAILDIR=$HOME/mail      # You'd better make sure it exists
        COMSAT=no               # Don't notify for incoming mail.
        LIBDIR=/etc/mail/rc.d   # Location of shared procmail scripts

        ### Initialize the Virtual Email Domain services.
        INCLUDERC=$LIBDIR/rc.init          # Leave this line alone.

        DOMAIN=___ENTER_YOUR_DOMAIN___
        :0
        * $ ENVELOPE_DOMAIN ?? $DOMAIN
        {
          ADDR=__email__  FRWD=__forward__       INCLUDERC=$LIBDIR/rc.deliver
          ADDR=__email__  FRWD=__forward__       INCLUDERC=$LIBDIR/rc.deliver
          ADDR=__email__  FILE=__file__          INCLUDERC=$LIBDIR/rc.deliver
          INCLUDERC=$LIBDIR/rc.term_dom    # Leave this line alone.
        }
        ------------------------------end----------------------------------

      This will even handle multiple domains, if a single user has more
      then one.  Simply create one recipe block for each domain.

        $LIBDIR/rc.init
        -----------------------------start---------------------------------
        ###  Get the Envelope recipient of the message.  The header
        ###  X-Envelope-To must be present to be able to process any
        ###  virtual domain mail.
        ENVELOPE_TO=`formail -zxX-Envelope-To:`

        ###  Grab the domain we are working with.
        :0
        * $ ENVELOPE_TO ?? @\/.*
        { ENVELOPE_DOMAIN=$MATCH }

        ###  Strip the X-Envelope-To header off, to avoid sending any BCC info.
        :0 fhw
        * ! DEBUG ?? .                     # Leave the header there if DEBUGing
        | formail -I"X-Envelope-To:"
        ------------------------------end----------------------------------

        $LIBDIR/rc.deliver
        -----------------------------start---------------------------------
        ###  If the message is addressed to the user defined in ADDR at domain
        ###  DOMAIN, then either forward (FRWD) or file (FILE) the message to
        ###  the appropriate destination.
        :0
        * $ ENVELOPE_TO ?? ^${ADDR}(_at_)${DOMAIN}
        {
          :0 c
          * FRWD ?? .
          ! ${FRWD}

          :0 a
          { FLAG=delivered }

          :0 wc:
          * FILE ?? .
          $FILE

          :0 a
          { FLAG=delivered }
        }

        ###  Clear these so they don't affect the next query
        FRWD
        FILE
        ------------------------------end----------------------------------

        $LIBDIR/rc.term_dom
        -----------------------------start---------------------------------
        OLDSHELL=${SHELL}                  # Just in case
        SHELL=/bin/sh

        ### if the mail was delivered to someone, stop now.  If there
        ### is another recipient, sendmail will send a new email (because
        ### we took out the 'm' procmail flag).
        ### If no matches were found, the mail will just "drop thru" to
        ### the owners mailbox.
        :0
        * FLAG ?? delivered
        { HOST=_stop_now_ }

        SHELL=${OLDSHELL}
        ------------------------------end----------------------------------

      There are other things I include in there, such as some default
      auto-responders, vacation messages, different notifications for
      unknown users, etc.  However, I can't give away ALL my secrets :)
      I also stripped out a lot of my comments, to save space in this
      email.

If you reply to this, please CC me, as I don't always get a chance to 
read all the procmail list messages.

Dan T.


<Prev in Thread] Current Thread [Next in Thread>
  • Bcc addresses, Dorita Menconi
    • Re: Bcc addresses, James L. McGill <=