iMS and SpamAssassin (populating OUTPUT_HEADERS unsuccessful)
Using iMS 5.2sp04 on Sol 8
Conversion channels work just fine (using it right now for Anti-Virus with success).
Trying to drop external mail through conversions to spamassassin for processing, but to no avail.
What I am able to do:
I can rewrite OUTPUT_FILE and pass on information
I can rewrite OUTPUT_HEADERS, but the changes don't take
This is what the conversion channel looks like at present:
!
in-channel=*; out-channel=*;
in-type=*; in-subtype=*;
message-header-file=2; original-header-file=1;
override-header-file=1; override-option-file=1;
command="/usr/iplanet/server5/msg-adhcpdns-1/imta/programs/tst.csh"
!
This is what tst.csh looks like:
#!/usr/bin/csh
mv $INPUT_HEADERS $OUTPUT_HEADERS
echo "X-Test: This is a test" >> $OUTPUT_HEADERS
mv $INPUT_FILE $OUTPUT_FILE
echo "This is a test" > $OUTPUT_FILE
What I'm running into:
I am able to manipulate the OUTPUT_FILE just fine. Anything I put in there ends up at the users' mail. However, though I am able to write to the OUTPUT_HEADERS, INPUT_HEADERS, MESSAGE_HEADERS, or other such files (env variables...), I still end up with the original headers by the time the message lands in the user's mail box.
Explanation of above settings:
in-channel=* --> for testing, we'll test ALL channels
out-channel=* --> ibid
message-header-file=2 --> have tried 0, 1, 2 to no avail
original-=header-file=1 --> have tried 0, 1 to no avail
override-header-file=1 --> have tried 0, 1 to no avail
override-optioni-file=1 --> have tried 0, 1 to no avail
I have replaced INPUT_HEADERS with:
MESSAGE_HEADERS
OUTPUT_HEADERS
ORIGINAL_HEADERS
in the script, to no avail.
Now, you wonder, so where is spamc in all of this? Well, I had to dumb it down to the csh above, since I wasn't getting the manipulation I was hoping for.
Using spamc, it would look something like this:
#!/bin/csh
set SERVER_ROOT =/usr/iplanet/server5
set INSTANCE=instance-name
set SPAMDIR="${SERVER_ROOT}/msg-${INSTANCE}/imta/queue/SPAMDIR" # Make sure this exists!!!
# Set a reference ID for the working file
set REFERENCE_ID=`/bin/cksum ${MESSAGE_HEADERS} | /bin/awk '{print $1}'`
set RECORD_FILE=${SPAMDIR}/SpamAssasin-${REFERENCE_ID}.spam # This is the file we'll use for processing
# put a blank in the INPUT_HEADERS file before feeding it to spamc
# This is because the HEADERS and FILE are separated in SMTP with a "\n", but they are
# not separated this way on the system
/bin/echo "" >> $INPUT_HEADERS
/bin/cat $INPUT_HEADERS $INPUT_FILE | /usr/local/bin/spamc -u spamd -f >& ${RECORD_FILE}
# Now, where does that first "\n" occur? In C-Shell, you cannot grep for "^$", which is more
# convenient. Furthermore, when you use the -n option in grep, you end up with
# a ':' separator and the name of the files. We have to stript this off.
# Finally, we subtract "1" so that we start at the proper location BEFORE
# the first "\n"
@ Split = `/bin/grep -nv "." ${RECORD_FILE} | /bin/head -1 | /bin/cut -f1 -d: ` - 1
# Now let's write out the HEADERS from the RECORD_FILE
/usr/bin/head -${Split} ${RECORD_FILE} >& $OUTPUT_HEADERS
#Shouldn't need to rewrite the body if you don't want the reports
#@ Split = $Split + 2
#/usr/bin/tail +${Split} ${RECORD_FILE} >& $OUTPUT_FILE
/bin/mv $INPUT_FILE $OUTPUT_FILE
# This is to demonstrate that spamc did it's processing, and everything worked....
cat $OUTPUT_HEADERS >> $OUTPUT_FILE
exit 0;
If you run it through this script, you will see that the RECORD_FILE (in SPAMDIR) gets the header rewrites just fine, and the OUTPUT_FILE gets populated with the header rewrites at the end. However, the OUTPUT_HEADERS don't follow the message through the messaging system, for some reason.....

