[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Exim vs Procmail (was: Sendmail vs Exim vs Others)



On Sat, Jan 31, 2004 at 01:09:21AM +0100, Vincent Lefevre wrote:
> * A result of a pipe can't be retrieved (and that's why the FAQ
>   recommends to use procmail for such things).

...you mean that if you pipe a message through some external program
you can't then feed the output of that program back into exim? It
initially appears so, but it's straightforward to write a shellscript
wrapper for the external program that adds a custom header (to avoid
loops) and feeds the output of the external program back in using
exim -bm. Useful if you want to avoid having to learn
Sanskrit^Wprocmail.

For example, the following is what I use to strip the advertising from
Yahoo Groups mailing list traffic:

------------/home/pigeon/.forward:
# Exim filter

if $header_to: contains "yahoogroups.com" and $header_X-Footer-Stripped: does not contain "yes"
then
    pipe "/home/pigeon/bin/yahoo.mail.footer.strip"
	save "/home/pigeon/mail/debug/yahoo.strip.log"
	seen finish
endif

------------/home/pigeon/bin/yahoo.mail.footer.strip:
#!/bin/sh
# /bin/sed -e '/---- Yahoo! Groups Sponsor ----/,$d' | /usr/sbin/exim -bm pigeon

LOGFILE="/home/pigeon/mail/debug/yahoo.strip.log"
SCRIPTFILE="/home/pigeon/bin/yahoo.mail.footer.strip.edscript"
TMPFILE=`mktemp -t footerstrip.$$.XXXXXXXXXX`
if [ $? -ne 0 ]; then
  (echo -n 'Error creating TMPFILE at '; 822-date) >> $LOGFILE
  cat | /usr/sbin/exim -bm pigeon
  exit 0
fi

cat > $TMPFILE
cat $SCRIPTFILE | ed $TMPFILE > /dev/null 2>/dev/null
cat $TMPFILE | /usr/sbin/exim -bm pigeon
rm -f $TMPFILE

------------/home/pigeon/bin/yahoo.mail.footer.strip:
$
?^--* Yahoo! Groups Sponsor --*~?
.,/-----------------------/d
1
/^$/
i
X-Footer-Stripped: yes
.
w
q


-- 
Pigeon

Be kind to pigeons
Get my GPG key here: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x21C61F7F

Attachment: pgpKW6pCqat9A.pgp
Description: PGP signature


Reply to: