procmail
[Top] [All Lists]

Capturing Harassing Emails

1999-08-06 09:52:05

    Hi, 
 
    I am attempting to use procmail to capture emails from a 
    particular email address (external) that has been harassing
    individuals here at our site (internal). What I would like to do
    is capture emails (not bounce) from that particular address, then 
    resend the email to two other individuals (internal) attached with 
    some remarks such as: 

   "The postmaster account has captured the following email from 
    harasser(_at_)outside(_dot_)com(_dot_) The email was not delivered to the 
target
    recipients, but this copy has been sent to you for your records".

    I have tried using the following .procmailrc I read about in 
    an answer posted by Alan K. Stebbens, which I modified a bit. 
    The filter does capture the message from the sending address and 
    forwards a copy with the add-on message to user1 and user2, but
    the problem is the email in user1 and user2 receives 1 header
    of the original message, but 2 bodys each time. Also, the
reject.mail
    file keeps receiving appended messages each successive capture
    so that each time user1 and user2 get an email, they see
    a long list of the previous captures. I tried adding an 
    "rm $REJECTMAIL" in various places to no avail.

    I am fairly new at procmail, so any suggestions, rewrites, 
    corrections, or different approaches are welcome.

    Thanks, Dave


    My .procmailrc:

    ########################################

    # A .procmailrc file to capture harassing emails from
    # an address or list of addresses and send to a copy
    # to one or two individuals
  
    # if you touch reject.rc.log, you'll get copious
    # logging info remove reject.rc.log after you're sure
    # it works.
 
    :0
    * ? test -f reject.rc.log
    { LOGFILE=reject.rc.log LOGABSTRACT=all VERBOSE=yes }
 
    REJECTFILE=reject-list      # file containing
                                # addresses to reject
                                # and bounce back mail to
 
    FORMAIL=formail             # /usr/local/bin/formail
 
    FROM=`formail -rtzXTo:`     # get who it's from
 
    # if the sender is in the reject file, then capture
    # and forward a copy to one or two individuals.
 
    :0 :$REJECTFILE.lock
    * $ ! ^X-Loop: *$LOGNAME(_at_)$HOST
    * ? grep -s "$FROM" $REJECTFILE
    {
      DELIVERED=yes           # tell sendmail that
                              # the mail was delivered
 
      COMSAT=no               # but be quiet about it
 
      # First make a copy of the entire mail
      REJECTMAIL=reject.mail
      LOCKFILE=$REJECTMAIL.lock
      :0c
      $REJECTMAIL
 
      # Replace the mail with a reply
      FROMSIG="$LOGNAME's Mailer-Daemon <$USER>"
      SUBJECT="This email has been captured/rejected"
 
      # (Note: do not use -k here; "h" recipes include
      # the blank line in the headers, and formail -r
      # generates a blank line also.  If you use '-k',
      # then the original blank line will be kept, and
      # the additional will be added, resulting in two
      # blank lines).
 
      :0 fhw
      | $FORMAIL -rtI"To:     user1(_at_)ourcompany(_dot_)com,  \
                              user2(_at_)ourcompany(_dot_)com"  \
               -I"From:       $FROMSIG"              \
               -I"Subject:    $SUBJ"                 \
               -I"X-Loop:     $LOGNAME(_at_)$HOST"        \
               -I"Precedence: junk"                  \
        ; echo "The postmaster account has captured" \
        ; echo "the following email and sent a copy" \
        ; echo "to you for your records."            \
        ; echo ""                                    \
        ; echo "The original mail follows:"          \
        ; echo "-------------------------------"     \
        ; cat $REJECTMAIL
 
 
        # release the lock file now
        LOCKFILE
 
        # Finally, deliver it
        :0 w
        ! -oi -t
 
 
        HOST=end_of_processing    # just in case sendmail failed
    }



reject.rc.log:
#######################################
procmail: [60920] Fri Aug  6 12:31:06 1999
procmail: Assigning "REJECTFILE=reject-list"
procmail: Assigning "FORMAIL=formail"
procmail: Executing "formail,-rtzXTo:"
procmail: Assigning "FROM=To: root"
procmail: Match on ! "^X-Loop: *atest(_at_)infoserver"
procmail: Executing "grep,-s,To: root,reject-list"
procmail: Match on "grep -s To: root reject-list"
procmail: Extraneous locallockfile ignored
procmail: Locking "reject-list.lock"
procmail: Unlocking "reject-list.lock"
procmail: Assigning "DELIVERED=yes"
procmail: [61444] Fri Aug  6 12:31:06 1999
procmail: Assigning "COMSAT=no"
procmail: Assigning "REJECTMAIL=reject.mail"
procmail: Assigning "LOCKFILE=reject.mail.lock"
procmail: Locking "reject.mail.lock"
procmail: Assigning "LASTFOLDER=reject.mail"
procmail: Opening "reject.mail"
From root  Fri Aug  6 12:31:06 1999
 Subject: test
  Folder: reject.mail                                567
procmail: Assigning "FROMSIG=atest's Mailer-Daemon <>"
procmail: Assigning "SUBJECT=This email has been captured/rejected"
procmail: Executing " $FORMAIL -rtI"To:     user1(_at_)ws-esg(_dot_)com,  \
                              user2(_at_)ws-esg(_dot_)com"     \
               -I"From:       $FROMSIG"             \
               -I"Subject:    $SUBJ"                \
               -I"X-Loop:     $LOGNAME(_at_)$HOST"       \
               -I"Precedence: junk"                 \
        ; echo "The postmaster account has captured" \
        ; echo "the following email and sent a copy" \
        ; echo "to you for your records."            \
        ; echo ""                                   \
        ; echo "Your original mail follows:"        \
        ; echo "-------------------------------"    \
        ; cat $REJECTMAIL  "
procmail: Assigning "LOCKFILE"
procmail: Unlocking "reject.mail.lock"
procmail: Executing "/usr/sbin/sendmail,-oi,-oi,-t"
procmail: [61444] Fri Aug  6 12:31:07 1999
procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi -oi -t"
 Subject:
  Folder: /usr/sbin/sendmail -oi -oi -t               3929

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