procmail
[Top] [All Lists]

RE: copying all mail matching a number of recipes to a single folder

2001-12-27 01:04:53
catching up on some mail ...

-----Original Message-----
From: procmail-admin(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE
[mailto:procmail-admin(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE]On Behalf Of 
Eric Smith
Sent: Tuesday, December 18, 2001 2:11 PM
To: Procmail List
Subject: copying all mail matching a number of recipes to a single
folder


So, i have a number of recipes for all the lists I subscribe to
viz.


*^From hylafax
hylafax-li
:0:
* ^From dreamcompany
dream-li
:0:
*^(From fop-user-return-|From www-xsl-fo-request)
fop-li
:0:
*^From owner-majordomo(_at_)power(_dot_)renderx(_dot_)com
xep-li
:0:
*^Mailing-List.*XSL-FO
fop-li
...

But I want to copy each of the mails caught by any of the above
into a single folder in addition to each of the above folders.

Martin McCarthy offered some alternatives:
 http://mailman.rwth-aachen.de/pipermail/procmail/2001-December/007500.html
and so did Andrew Edelstein:
 http://mailman.rwth-aachen.de/pipermail/procmail/2001-December/007553.html

Here are a couple of other methods, just to cover the spectrum:

1) Use the LASTFOLDER variable, per "man procmailrc":
     LASTFOLDER  This variable is assigned to by  procmail  when-
                 ever  it  is  delivering to a folder or program.
                 It always contains the name of the  last  folder
                 (or program) procmail delivered to.
   This can eliminate the need to set the folder name explicitly. Using your
example, above,
   and assuming that "common.mbox" is the folder where all messages matching
a specific
   set of criteria will be also be delivered, your example might read:

# Clear LASTFOLDER ahead of the following delivery recipes.
LASTFOLDER=
:0 c:
*^From hylafax
hylafax-li
:0 cE:
* ^From dreamcompany
dream-li
:0 cE:
*^(From fop-user-return-|From www-xsl-fo-request)
fop-li

#
# If the recipes above delivered (a copy of) the mail, then perform
# a final delivery to the common mail box
#
:0:
* LASTFOLDER ?? .
common.mbox
#
# Otherwise, continue processing the undelivered message ...
#

The recipe above is just a variant of Martin's approach, using prcomail's
builtin
$LASTFOLDER variable, instead of using a user-specified variable that
contains the
name of the mailbox where the message is to be delivered.

2) pipe the output to the "tee" command:

  *^From hylafax
  | tee -a hylafax-li >> common.mbox

This isn't as efficient as Martin's solution, because it creates a shell
process to run
the "tee" commmand, but it is terse, and should work fine for infrequent
use.

3) if you're using mail directories for delivery (and you're not in your
example), you
can specify more than on mail directory on the delivery line, per "man
procmailrc":

     When  procmail is delivering to directories, you can specify
     multiple directories to deliver to (using hardlinks).

:0 c:
*^From hylafax
hylafax-maildir commom-maildir
:0 cE:
* ^From dreamcompany
dream-maildir common-maildir
:0 cE:
*^(From fop-user-return-|From www-xsl-fo-request)
fop-maildir common-maildir

(I'm not sure if this multiple delivery feature, since I haven't used it,
and
would appreciate confirmation on its usage).


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail