[ I am forwarding this to the qmail list; perhaps somebody has a
better idea what to do ]


So I think I understand your problem completely: the problem is that
upon postmaster receiving the message from the isp, you want to
forward the message to only the local addresses that appear in 

To, Cc, Bcc, Apparently-To, Resent-To, Resent-Cc, Resent-Bcc.

(I'd like to remark that it is not a great idea for the isp to send the
messages to postmaster, it would be better to send it to some generic
user [like isp, or sg].  How would you then deliver messages that were
directly addressed to postmaster?)

In any case, at this point I can suggest only the following solution.

Namely, I will give an idea how to construct a program that would
filter out the local recipient addresses.

First, qmail's author has the package 822mess.  (I have an rpm for it
if you are running Linux).  This package has tools to parse, and
rewrite messages.

We will need two programs: new-inject and 822field.

In the future, new-inject is going to be the replacement of qmail-inject.
This new-inject collects all recipient addresses (addresses from the
fields listed above) in an easily parsed form; they are put in the
header Envelope-Recipients.  To illustrate, I do

$ echo 'To: Mate <mw>, mo, [EMAIL PROTECTED]'|new-inject -n

and I get

Envelope-Sender: [EMAIL PROTECTED]
Envelope-Recipients:
  [EMAIL PROTECTED],
  [EMAIL PROTECTED],
  [EMAIL PROTECTED],
Date: 6 Jan 1999 19:15:59 -0000
Message-ID: <[EMAIL PROTECTED]>
From: [EMAIL PROTECTED]
To: "Mate" <[EMAIL PROTECTED]>, [EMAIL PROTECTED],
  [EMAIL PROTECTED]

(the -n option just gives the message to stout instead of sending it).

Now 822field prints a specified field.  In our case, I do

$ echo 'To: Mate <mw>, mo, [EMAIL PROTECTED]' | new-inject -n | 822field 
envelope-recipients

and get 

  [EMAIL PROTECTED],  [EMAIL PROTECTED],  [EMAIL PROTECTED],

which it seems easy to parse with awk, for example, to pick up local
addresses.

Let us call the whole program that prints out the local addresses
localaddrs. (localaddrs looks like 

new-inject -n | 822field envelope-recipients | awk '...' 

)

Then put the following  in ~alias/.qmail-postmaster:

| if [ "`localaddrs`" != "" ]; then new-inject -a `localaddrs`; else exit 99; fi

(or exit 0 if you want the rest of the .qmail-postmaster file
processeed).

Mate
---
Mate Wierdl | Dept. of Math. Sciences | University of Memphis  

Reply via email to