[Mimedefang] Re: Automatically save spam/ham?
Doug Brott
brott at redh.com
Thu Apr 15 12:54:02 EDT 2004
Ken Morley wrote:
>On Wed, 14 Apr 2004, Ken Morley wrote:
>
>
>
>
>I added the following to aliases:
> local-ham-archive: /etc/mail/spamassassin/corpus/ham
> local-spam-archive: /etc/mail/spamassassin/corpus/spam
>
>
>This works as I requested (be careful what you wish for), but it puts all
>spams in a single file called "spam". I was hoping to build a corpus of
>seperate files named with the message ID or some other unique identifier.
>That would let me maintain a "current" corpus, by automatically deleting
>older files, etc. Also, I don't know whether sa-learn will work with
>multiple messages in a single file. Finally, I would prefer the message get
>saved without the SpamAssassin.txt attachment - this method includes
>everything.
>
>Any other ideas?
>
>
>
Ken,
Assuming you are using sendmail for your MTA and procmail for
delivery, there is a very easy way to accomplish this. First you will
need to create a dummy account to collect messages, say
'collector at domain.com'. Then you will edit your ~collector/.procmailrc
file as follows:
#-- Top of .procmailrc --
SHELL=/bin/sh
PATH=/usr/local/bin:/usr/bin:/usr/sbin
# Store HAM
:0
* ^TO_.*(ham at domain.com)
$HOME/corpus/ham/
# Store SPAM
:0
* ^TO_.*(spam at domain.com)
$HOME/corpus/spam/
# Dump all other messages
:0
/dev/null
#-- End of .procmailrc --
Please note the trailing slash (/) on the paths above. The trailing
slash is necessary for procmail to deliver the messages in Maildir
format instead of mbox format.
This will allow all messages sent to 'collector+ham at domain.com' to be
delivered into ~collector/corpus/ham and messages sent to
'collector+spam at domain.com' into ~collector/corpus/spam with the added
feature of splitting the messages for you.
Your alias file can then be changed as follows:
local-ham-archive: collector+ham at domain.com
local-spam-archive: collector+spam at domain.com
Of course, you could send directly to the addresses rather than the
aliases if you prefer.
Maildir format creates a 'cur', 'new', and 'tmp' directory under the top
level directory. This is part of the protocol, so you may hve to look
in any or all of these directories for messages. However, each file (an
any directory) will be a single message that has been delivered to this
account
If you want to pipe the message directly into SpamAssassin without human
intervention, there are procmail rules to help do that as well.
However, I will leave that as an excercise for others to complete.
Hopefully this is in line with what you are looking for.
--
Doug Brott
brott at redh.com
More information about the MIMEDefang
mailing list