In message <486E8EDA(_dot_)9000205(_at_)pelorus(_dot_)org>,
Skip (skip(_at_)pelorus(_dot_)org) wrote:
I'm trying to write a recipe that has several blocks which check for
certain spam conditions, added by spamassassin and dspam. When those
conditions are met, it should
1. Add a header to the email which tells me what rule filed the email
so I won't have to go through the logs
2. Deliver the message
3. Mark it read
4. Learn it with sa-learn as spam
I think I have tried every combination placement and header options, but
I haven't nailed the right combination just yet. Perhaps one of you
smart readers can help me?
Lets see if I can help. I have never used spamassassin - I was put off
by all the negative comments floating around on various mailing lists -
and although I did consider using dspam I opted for bogofilter which I
find to be excellent and very easy to use.
Here's where I am now. This actually does everything it's supposed to,
but I get extra emails from all the extra clonings (sometimes a message
may meet the conditions of more than one block).
:0c
Why is this a "copy" when you have HOST at the end?
* ^X-Spam-Status:.*autolearn=no
* ^X-Spam-Status:.*BAYES_99
* ^X-DSPAM-Result: Spam
{
foldername=Spam-Archive
#add the header
:0fhw:formail.lock
|/usr/bin/formail -A "X-Procmail-Rule: spamassassin autolearn=no, BAYES_99
and dspam-result=spam"
#delivers to foldername/new
:0c:
.$foldername/
No need for locking on maildir mailboxes, so drop the second colon.
#moves it to foldername/cur and marks it read
:0
* LASTFOLDER ?? /\/[^/]+$
{ tail = $MATCH }
TRAP = "mv $LASTFOLDER .$foldername/cur/$tail:2,S"
I do this slightly differently in that I get the sub-shell to do all the
substitution. I find it more readable, for some value of readable! ;-)
:0
* some-regexp
{
TRAP='mv ${LASTFOLDER} ${LASTFOLDER%%new/*}cur/${LASTFOLDER##*/}:2,S'
:0
some-folder/
}
This subject was discussed last year. For more detail see:
http://www.xray.mpe.mpg.de/mailing-lists/procmail/2007-08/msg00023.html
So, using your example above, I would have:
:0
* ^X-Spam-Status:.*autolearn=no
* ^X-Spam-Status:.*BAYES_99
* ^X-DSPAM-Result: Spam
{
foldername=Spam-Archive
TRAP='mv ${LASTFOLDER} ${LASTFOLDER%%new/*}cur/${LASTFOLDER##*/}:2,S'
:0fhw:formail.lock
|/usr/bin/formail -A "X-Procmail-Rule: spamassassin autolearn=no, BAYES_99 and
dspam-result=spam"
:0
.$foldername/
}
Does that help?
Cheers,
Nick.
--
Thanks to the IAU Gustav Holst can now rest easy in his grave. As for
Mr. Colin Matthews, I suggest he look elsewhere for employment, perhaps
as a vampire!
____________________________________________________________
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