[wplug] procmail help

Chester R. Hosey chosey at nauticom.net
Sun May 21 19:52:29 EDT 2006


Gentgeen wrote:
> On Sun, 21 May 2006 12:45:31 -0400
> 
> MAN -- I owe you a beer (add "root" if under 21). Great job. I want to
> make sure I understand this first though :-)

Bah! I thought that this was the sort of thing the list was intended
for. Although I'm always taking suggestions for interesting beers to try
if you know any. ;)

> Fetchmail grabs all the mail from all the accounts, and passes them
> along as if $USER=kevin (me).  Formail adds headers where necessary, and
> continues to pass them along as if $USER=kevin.  Then procmail takes
> over, and since $USER=kevin, it is going to use /home/kevin/.procmailrc
> to do the sorting.  Using the procmail config file you posted earlier -
> a copy of the email will be sent to either "val at localhost.localdomain"
> or "ariel at locahost.localdomain" for those with the header changes and a
> copy will also be placed in my $MAILDIR folders.  

You got it! As you'd said, it's not quite the same as forwarding it to
the other addresses from a mail client, as the mail headers won't be
rewritten. As far as your family members will see it, the mail comes
straight from the original sender to their mailbox.

Also, you are correct that the only .procmailrc that needs to be set up
for this is your own, since everything will be sent to your account and
forwarded as needed.

>
> I used the quotes around the local email addresses cause I imagine
> that it is not exactly the same thing as mailing directly to them
> (i.e. your method will not change the TO or the REPLY-TO fields for
> example).
>
> I could then add all my other sorting stuff below that right?  After
> the Ariel sort, but before the Unsorted gets dropped into $DEFAULT.
>

The sample procmail setup I gave won't quite work that way -- I'd
assumed that the filtering had been done *before* all of that in the
.procmailrc, and that it was okay just to dump it all into your mailbox
without proceeding through the rest of the filter.

If you want the mail to be able to filter these emails further before
just dropping them in your mailbox, it's an easy change. Something like
the following should work:


######################################################
# Filtering can be done here, such as using
# spamassassin or clamav. If mail (such as spam) is
# dropped into a separate mailbox at this point, it
# will not continue through to be forwarded to Val
# or Ariel (if appropriate).
######################################################


#---------------------------------
# Family Email account -- send a copy
# to Val and continue processing
:0 c
* ^X-Original-Account:.*kvsquire at comcast.net
! val


######################################################
# If filtering for spam is done at this point, Val
# will have gotten a copy of mail tagged as spam (if
# it's sent to kvsquire at comcast.net, that is), but
# Ariel won't.
######################################################


#---------------------------------
# Ariel's account -- send her a copy
# and continue processing
:0 c
* ^X-Original-Account:.*bratzfan7 at comcast.net
! ariel


######################################################
# At this point, Val and Ariel have received their
# email, but it hasn't yet been dropped into Kevin's
# mailbox. Further sorting can occur right here,
# such as running clamav or spamassassin, and mail
# that is diverted into another mailbox at this point
# will still have been delivered to Val or Ariel if
# appropriate.
######################################################


# Uncomment the following to drop Comcast mail into
# another mailbox:

# :0 c
# * ^X-Original-Account:.*@comcast.net
# $MAILDIR/Other_Acct/comcast/.


#---------------------------------
# This drops any Unsorted mail into the INBOX
:0
$DEFAULT/.
#----------------------------------



If you sort mail into another mailbox before looking for the
X-Original-Account header, processing will stop and the mail won't be
filtered by rules later in the file. This gives some flexibility -- for
instance, if spamassassin marks a message as spam, you might not mind if
Val gets a copy, but you might want to prevent Ariel from seeing it
until you decide whether it's actually spam. This is done by dropping
the message into your "spam" mailbox after Val's mail is forwarded, but
before Ariel gets hers.

Hopefully the comments in the example are clear enough to explain it
all. If not, or if you have any other questions, you know the drill. ;)

Chet



More information about the wplug mailing list