procmail
[Top] [All Lists]

body striped from forwarded messages

2007-10-15 02:12:00
I was trying to amend Nic's Spam-X script to add some preprocessing and spam 
checking.  It was working fine - that is delivering mail to appropriate folders 
and doing spam checks -  but then an odd thing started happening (really, for 
no apparent reason).  If any of the pre-filtering was triggered (by the grep 
tests, see the script below) it caused the mail to be delivered (to the correct 
folder) without any body (that is just the message head, the body blank).  The 
save_all file showed the full message (no mail was lost) but the delivered 
message had nobody.


# Blocking spam with an accept list, version 070514
# Info at http://angel.net/~nic/spam-x.html


# Customize all these constants:

# Your e-mail address
MY_EMAIL=gessel(_at_)blackrosetech(_dot_)com

# Your name
MY_NAME="David Gessel"

# This should be either blank, or a regex that matches any addresses from which 
# you get lots of mail that you want to archive but not read:
#BOTS=(root(_at_)(_dot_)*angel(_dot_)net|domainA|domainB|domainC)
#BOTS=()

# This should be a regex that matches all domains from which you know you
# won't get spammed:
#KNOWN_DOMAINS=(angel.net|domain1.com|domain2.com)$
KNOWN_DOMAINS=(mit.edu|americancapital.com)$

# This should be either blank, or a regex that matches the To: headers of any # 
mailing lists you're on:
LISTS=


# Customize this to change the autoreply sent to messages from addresses
# that are not in the accept list
AUTOREPLY="Hi!

Your message has been received, but it hasn't been delivered to me yet. Since I 
don't have any record of your sending me mail from this address before, I need 
to verify that you're not a spammer. Please just hit 'Reply' and send this 
message back to me, and your previous message will be delivered, as will all 
your future messages.
Thanks, and sorry for the inconvenience -"


# Customize these if they're not right on your system:
FORMAIL=/usr/local/bin/formail
GREP=/usr/bin/grep
HEAD=/usr/bin/head
POSTFIX=/usr/local/sbin/postfix
SENDMAIL=/usr/sbin/sendmail
LS=/bin/ls
TR=/usr/bin/tr
SHELL=/bin/sh
PATH=/usr/bin:/bin:/usr/local/bin:.

# Customize these if you want to put addresses and pending messages elsewhere -
# make sure PENDING_DIR exists!
DB=$HOME/.procmail/accept-list
DENY_DB=$HOME/.procmail/deny-list
DEFAULT=$HOME/Maildir/
PENDING_DIR=$HOME/pending_messages
MAILDIR=$HOME/Maildir/
PMDIR=$HOME/.procmail
VERBOSE=yes
LOGFILE=$HOME/ProcmailLog
LOCKFILE=$HOME/.lockmail

# Sorting lists on server
BULK=$HOME/.procmail/bulk-list
BSD=$HOME/.procmail/bsd-list
COM=$HOME/.procmail/commerce-list
IMP=$HOME/.procmail/impersonal-list
SRL=$HOME/.procmail/srl-list
TRAV=$HOME/.procmail/travel-list

##############################
# Don't change anything else unless you know why you're doing it!

SHELL=/bin/sh
PATH
COMSAT
VERBOSE=on
#LOGFILE=${LOGFILE-".procmail_log"}

:0 c
$HOME/.save_all

# You can mail yourself a request for the list of pending senders
:0
* ^Subject: List senders
{
 :0 fbw
    | $LS -t $PENDING_DIR
    :0:
    ${DEFAULT}
}

# You can mail yourself to approve an address
:0 fw
* ^Subject: Accept \/.*
* ? echo $MATCH >> $DB
* ? test -e $PENDING_DIR/$MATCH
| ( cat $PENDING_DIR/$MATCH || true )

# You can mail yourself to deny an address
:0 fw
* ^Subject: Deny \/.*
* ? echo $MATCH >> $DENY_DB
/dev/null

# Get sender
:0 hw
FROM=|$FORMAIL -rzxTo:|$TR / _

# If message is from a local bot then archive it
#:0
#* BOTS ?? (.)
#* $ FROM ?? $BOTS
#notifications

# If message is an NDN then archive it
:0 h
* MAILER-DAEMON
NDNs

# If message is from a known domain then deliver it
:0
* KNOWN_DOMAINS ?? (.)
* $ FROM ?? $KNOWN_DOMAINS
$DEFAULT

# whitelist check
:0 h
* ? $GREP -i ^$FROM $DB
$DEFAULT

# If message is to a list we're on then deliver it
:0
* LISTS ?? (.)
* $ ^TO_$LISTS
$DEFAULT

# Checks bulkmail sources
:0 h
* BULK ?? (.)
* ? $GREP -i ^$FROM $BULK
.Bulkmail/

# checks BSD sources
:0 h
* BSD ?? (.)
* ? $GREP -i ^$FROM $BSD
.BSD/

# checks Commerce sources
:0 h
* COM ?? (.)
* ? $GREP -i ^$FROM $COM
.Commerce/

# Insert checks for lists here, move to appropriate mailbox
#:0
#* IMP ?? (.)
#* $ FROM ?? $IMP
#Impersonal

# checks SRL sources
:0 h
* SRL ?? (.)
* ? $GREP -i ^$FROM $SRL
.SRL/

# checks Travel (reservations) sources
:0 h
* TRAV ?? (.)
* ? $GREP -i ^$FROM $TRAV
.Travel/

# If message is from a known non-spam UCE sender then dump it
:0 h
* ? $GREP -i ^$FROM $DENY_DB
/dev/null

# Else if message has chicken then register sender and deliver stored messages
:0 Efw
* $ ^Subject:.*Verify.*for.*$MY_EMAIL
* $ ^Subject:.*Verify \/[^ ]+
* ? echo $MATCH >> $DB
* ? echo $FROM >> $DB
* ? test -e $PENDING_DIR/$MATCH
| ( ( cat $PENDING_DIR/$MATCH && rm $PENDING_DIR/$MATCH ) || true )
SPAM CHECK - if the message isn't spammy, deliver it.
:0fw: spamassassin.lock
| /usr/local/bin/spamc

# The following three lines move messages tagged as spam to a folder
# called "spam-folder" If you want mail to stay in your inbox, just
# delete the lines

:0:
* ^X-Spam-Status: No
$DEFAULT


# Else if sender isn't in DB then send request for chicken and store message
:0 E
* $ ! ^X-Loop: $MY_EMAIL
* ! ? $GREP -i ^$FROM $DB
{
    :0 c
    * ? test ! -e $PENDING_DIR/$FROM
    | ( $FORMAIL -rt -I"To: $FROM" -A"X-Loop: $MY_EMAIL" -I"Subject: Verify 
$FROM for $MY_EMAIL"; echo "$AUTOREPLY"; echo; echo "$MY_NAME" ) | $SENDMAIL -t

    :0:
    $PENDING_DIR/$FROM
}

# Else deliver normally


LOG FILES


THIS MESSAGE WAS PROCESSED WITH THE BODY INTACT
(I removed the 'from' address from the "accept-list")

procmail: Unlocking "/home/gessel/.lockmail"
procmail: Assigning "LOCKFILE=/home/gessel/.lockmail"
procmail: Locking "/home/gessel/.lockmail"
procmail: Assigning "BULK=/home/gessel/.procmail/bulk-list"
procmail: Assigning "BSD=/home/gessel/.procmail/bsd-list"
procmail: Assigning "COM=/home/gessel/.procmail/commerce-list"
procmail: Assigning "IMP=/home/gessel/.procmail/impersonal-list"
procmail: Assigning "SRL=/home/gessel/.procmail/srl-list"
procmail: Assigning "TRAV=/home/gessel/.procmail/travel-list"
procmail: Assigning "SHELL=/bin/sh"
procmail: Assigning "PATH"
procmail: Assigning "COMSAT"
procmail: Assigning "VERBOSE=on"
procmail: Assigning "LOGFILE=/home/gessel/ProcmailLog"
procmail: Opening "/home/gessel/ProcmailLog"
procmail: Assigning "LASTFOLDER=/home/gessel/.save_all"
procmail: Opening "/home/gessel/.save_all"
procmail: Acquiring kernel-lock
procmail: No match on "^Subject: List senders"
procmail: No match on "^Subject: Accept \/.*"
procmail: No match on "^Subject: Deny \/.*"
procmail: Extraneous filter-flag ignored
procmail: Assigning "FROM="
procmail: Executing "$FORMAIL -rzxTo:|$TR / _"
procmail: No match on "MAILER-DAEMON"
procmail: Match on "(.)"
procmail: No match on "(mit.edu|americancapital.com)$"
procmail: Executing 
"/usr/bin/grep,-i,^dgessel(_at_)gmail(_dot_)com,/home/gessel/.procmail/accept-list"
procmail: Non-zero exitcode (1) from "/usr/bin/grep"
procmail: No match on "/usr/bin/grep -i ^dgessel(_at_)gmail(_dot_)com 
/home/gessel/.procmail/accept-list"
procmail: No match on "(.)"
procmail: Match on "(.)"
procmail: Executing 
"/usr/bin/grep,-i,^dgessel(_at_)gmail(_dot_)com,/home/gessel/.procmail/bulk-list"
procmail: Non-zero exitcode (1) from "/usr/bin/grep"
procmail: No match on "/usr/bin/grep -i ^dgessel(_at_)gmail(_dot_)com 
/home/gessel/.procmail/bulk-list"
procmail: Match on "(.)"
procmail: Executing 
"/usr/bin/grep,-i,^dgessel(_at_)gmail(_dot_)com,/home/gessel/.procmail/bsd-list"
procmail: Non-zero exitcode (1) from "/usr/bin/grep"
procmail: No match on "/usr/bin/grep -i ^dgessel(_at_)gmail(_dot_)com 
/home/gessel/.procmail/bsd-list"
procmail: Match on "(.)"
procmail: Executing 
"/usr/bin/grep,-i,^dgessel(_at_)gmail(_dot_)com,/home/gessel/.procmail/commerce-list"
procmail: Non-zero exitcode (1) from "/usr/bin/grep"
procmail: No match on "/usr/bin/grep -i ^dgessel(_at_)gmail(_dot_)com 
/home/gessel/.procmail/commerce-list"
procmail: Match on "(.)"
procmail: Executing 
"/usr/bin/grep,-i,^dgessel(_at_)gmail(_dot_)com,/home/gessel/.procmail/srl-list"
procmail: Non-zero exitcode (1) from "/usr/bin/grep"
procmail: No match on "/usr/bin/grep -i ^dgessel(_at_)gmail(_dot_)com 
/home/gessel/.procmail/srl-list"
procmail: Match on "(.)"
procmail: Executing 
"/usr/bin/grep,-i,^dgessel(_at_)gmail(_dot_)com,/home/gessel/.procmail/travel-list"
procmail: Non-zero exitcode (1) from "/usr/bin/grep"
procmail: No match on "/usr/bin/grep -i ^dgessel(_at_)gmail(_dot_)com 
/home/gessel/.procmail/travel-list"
procmail: Executing 
"/usr/bin/grep,-i,^dgessel(_at_)gmail(_dot_)com,/home/gessel/.procmail/deny-list"
procmail: Non-zero exitcode (1) from "/usr/bin/grep"
procmail: No match on "/usr/bin/grep -i ^dgessel(_at_)gmail(_dot_)com 
/home/gessel/.procmail/deny-list"
procmail: No match on 
"^Subject:(_dot_)*Verify(_dot_)*for(_dot_)*gessel(_at_)blackrosetech(_dot_)com"
procmail: Locking "spamassassin.lock"
procmail: Executing "/usr/local/bin/spamc"
procmail: [2653] Mon Oct 15 00:02:46 2007
procmail: Unlocking "spamassassin.lock"
procmail: Match on "^X-Spam-Status: No"
procmail: Locking "/home/gessel/Maildir/.lock"
procmail: Assigning 
"LASTFOLDER=/home/gessel/Maildir/new/1192431759.2653_3.claudel.blackrosetech.com"
procmail: Unlocking "/home/gessel/Maildir/.lock"
procmail: Notified comsat: 
"gessel(_at_)0:/home/gessel/Maildir/new/1192431759.2653_3.claudel.blackrosetech.com"
From dgessel(_at_)gmail(_dot_)com  Mon Oct 15 00:02:39 2007
Subject: test with spamd running
 Folder: /home/gessel/Maildir/new/1192431759.2653_3.claudel.blackrose     2501

THIS MESSAGE WAS DELIVERED WITHOUT THE BODY
(The sender was in the accept-list)

procmail: Unlocking "/home/gessel/.lockmail"
procmail: Assigning "LOCKFILE=/home/gessel/.lockmail"
procmail: Locking "/home/gessel/.lockmail"
procmail: Assigning "BULK=/home/gessel/.procmail/bulk-list"
procmail: Assigning "BSD=/home/gessel/.procmail/bsd-list"
procmail: Assigning "COM=/home/gessel/.procmail/commerce-list"
procmail: Assigning "IMP=/home/gessel/.procmail/impersonal-list"
procmail: Assigning "SRL=/home/gessel/.procmail/srl-list"
procmail: Assigning "TRAV=/home/gessel/.procmail/travel-list"
procmail: Assigning "SHELL=/bin/sh"
procmail: Assigning "PATH"
procmail: Assigning "COMSAT"
procmail: Assigning "VERBOSE=on"
procmail: Assigning "LOGFILE=/home/gessel/ProcmailLog"
procmail: Opening "/home/gessel/ProcmailLog"
procmail: Assigning "LASTFOLDER=/home/gessel/.save_all"
procmail: Opening "/home/gessel/.save_all"
procmail: Acquiring kernel-lock
procmail: No match on "^Subject: List senders"
procmail: No match on "^Subject: Accept \/.*"
procmail: No match on "^Subject: Deny \/.*"
procmail: Extraneous filter-flag ignored
procmail: Assigning "FROM="
procmail: Executing "$FORMAIL -rzxTo:|$TR / _"
procmail: Match on ! "^Content-Length:"
procmail: Executing "/usr/local/bin/formail,-a,Content-Length: 0000000000"
procmail: No match on "MAILER-DAEMON"
procmail: Match on "(.)"
procmail: No match on "(mit.edu|americancapital.com)$"
procmail: Executing 
"/usr/bin/grep,-i,^dgessel(_at_)gmail(_dot_)com,/home/gessel/.procmail/accept-list"
procmail: Match on "/usr/bin/grep -i ^dgessel(_at_)gmail(_dot_)com 
/home/gessel/.procmail/accept-list"
procmail: Assigning "LASTFOLDER=$(DEFAULT}"
procmail: Opening "$(DEFAULT}"
procmail: Acquiring kernel-lock
procmail: [2856] Mon Oct 15 00:09:02 2007
procmail: Notified comsat: "gessel(_at_)0:/home/gessel/Maildir//$(DEFAULT}"
From dgessel(_at_)gmail(_dot_)com  Mon Oct 15 00:09:01 2007
Subject: test with message length thing
 Folder: $(DEFAULT}                                                       1974
procmail: Unlocking "/home/gessel/.lockmail"
____________________________________________________________
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

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