procmail
[Top] [All Lists]

Re: [PROCMAIL] stripping the email body

1998-04-03 23:55:13

"Terrance" == Terrance  <trife(_at_)pathway1(_dot_)pathcom(_dot_)com> 
writes:

    Terrance>   Hi, I have a question and hope someone can help me.  I
    Terrance> want to use procmail to forward an email to another
    Terrance> address but with the body stripped, so it only shows the
    Terrance> TO: and FROM:.  I also want to be able to keep a copy on
    Terrance> the same account the mail is being forwarded from.  Can
    Terrance> anyone help me on this? it would be greatly apreciated.

Not exactly the same thing, but here's something I worked up to notify
on the arrival of mail at a remote account.  It extracts the From: and
Subject: fields.  Not sure why you would want the To: field, since
that would seem obvious.  Anyway, you should be able to adapt this to
your needs.

mp

                Michael Powe       looie(_at_)teleport(_dot_)com
                 pgpk -a finger://teleport.com/looie
  Portland, Oregon, USA   "Home of the Summer Wiener Dog Nationals"

8<--------------------test.rc---------------------------------------->8

#######################################################################
# A test.rc for procmail to forward the contents of an e-mail From:   #
# line and Subject: line to another address; while spooling a copy of #
# the original mail.                                                  #
#######################################################################
# The idea here is to be notified when messages from certain persons  #
# or on specific subjects arrive at a remote account.                 #
# I suspect this could <really> slow down mail delivery if every      #
# incoming message passed through it.  But that could be done simply  #
# by setting the variables appropriately.                             #
# Michael A. Powe  Fri Apr  3, 1998  9:51 PM                          #
#######################################################################

PATH=/sbin:/bin:/usr/bin:/usr/local/bin:.
MAILDIR=$HOME/Mail
SHELL=/bin/sh
LOGFILE=$HOME/test.log
VERBOSE=on

# Reset these to reflect the values you want to use.

LOCAL_ADDR=${LOCAL_ADDR:-"looie(_at_)teleport(_dot_)com"}
TEST_SUBJ=${TEST_SUBJ:-"Guy's Test Message"}
ORIG_SENDER=${ORIG_SENDER:-"looie(_at_)europa(_dot_)com"}
FORWARD_TO=${FORWARD_TO:-"vargas(_at_)europa(_dot_)com"}

:0 
* $ ! X-Loop: $LOCAL_ADDR
* $ ^TO.*$LOCAL_ADDR
* $ ^From:.*$ORIG_SENDER
* $ ^Subject:.*$TEST_SUBJ
{
FROM=${FROM:-`formail -xFrom:`}
SUBJ=${SUBJ:-`formail -xSubject:`}

:0 ch
| (/usr/bin/formail -I "From:  $LOCAL_ADDR" \
            -I "To: $FORWARD_TO" \
            -I "Subject: Message Arrival Notification" \
            -A "X-Loop: $LOCAL_ADDR" \
            -A "Precedence: junk" ; \
echo "$FROM sent you a message about $SUBJ") | /usr/sbin/sendmail -t -oi
}
# if you want the original To: header, then
# echo "$FROM sent you a message at $LOCAL_ADDR"
# would do it.

8<--------------------test.rc---------------------------------------->8

<Prev in Thread] Current Thread [Next in Thread>