At 09:28 2010-09-30, Alex Rodriguez wrote:
Is there a better, more compact way of doing this?
[snip]
# Forward
{
# The bracing is superfluous if this isn't being used to group the
# action of a recipe.
# First, save original subject
ORIGSUBJECT=`formail -c -xSubject:`
# alternative - this doesn't require running an external process
# this is straight out of my sandbox (see .sigline)
:0
* ^Subject:[ ]*\/[^ ].*
{
SUBJECT=$MATCH
}
:0fwh
# Modify the subject line
* ^Subject: \/.*
| formail -I"Subject: [MODIFIED] $MATCH"
# Forward
:0c
! alex(_at_)spectrecom(_dot_)com
# Note that if you just saved the subject, there's no need to
# get a match for it in the very next recipe - you could use the
# SUBJECT from the capture.
# replace with:
# copy the message - the modification and delivery are of that copy
:0c
{
:0fwh
| formail -I"Subject: [MODIFIED] $SUBJECT"
:0
! alex(_at_)spectrecom(_dot_)com
}
# second method - streamline it:
# fwh unnecessary because you're not keeping the modified message
# in procmail. $SENDMAIL is the MSA program as determined by
# procmail (or overridden by you), not necessarily sendmail itself.
:0c
| formail -I"Subject: [MODIFIED] $SUBJECT" | \
$SENDMAIL alex(_at_)spectrecom(_dot_)com
# third method - streamline and roll in the subject capture
# Eliminate the generic subject capture (which as I said, is part of
# my standard sandbox - it's just available to all my recipes, so
# doesn't "cost" me anything on a per-recipe basis), and roll that
# into the formail. Just in case the subject is absent, we use
# scoring, otherwise, the action would not be taken:
:0c
* 1^0
* 1^0 ^Subject:[ ]*\/[^ ].*
| formail -I"Subject: [MODIFIED] $MATCH" | \
$SENDMAIL alex(_at_)spectrecom(_dot_)com
# Put back the original subject and submit to ${DEFAULT}
:0fwh
| formail -I"Subject:$ORIGSUBJECT"
# if you don't modify the original message, no need to undo
the change,
# so this would simply be omitted entirely.
:0:
| $DOVECOT_DELIVERY
}
# if you deleted the opening brace, be sure to do the same for
# the close.
I put comment prefixes on the above texts so that it's be clearer
what was code and what wasn't. Code is untested.
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail