[Mimedefang] tagging and redistributing selected messages

Steffen Kaiser skmimedefang at smail.inf.fh-bonn-rhein-sieg.de
Mon Feb 6 04:17:03 EST 2012

Hash: SHA1

On Sat, 4 Feb 2012, Fred Bacon wrote:

> for our employees.  She can't maintain separate mailing lists for each
> journal, so everyone gets everything.  So here's my plan to solve this

Some sort of mailing list seems to be appropriate, IMHO.

> I'm setting up a GNU Mailman mailing list (internal to the company)
> that uses "topics" to allow individuals to select which tables of

This is the important part: each user can (un-)subscribe self. Once 
accepted by the user base, you have less administrative tasks. However, a 
mailing list manager allows more things to do, usually people tend to 
request to use those new features, such as archiving the posts and 
searching through it.

> contents they want to receive.  To do this, we need to identify and
> tag all incoming messages which are tables of content alerts.  To do
> this, I'm writing a set of rules for SpamAssassin that will identify
> the TOC alerts using a set of rules for each journal.  So the Journal
> of Physical Chemistry will have a SpamAssassin rule with the name
> JPhysChem and a score that is either neutral or negative.

In my eyes, it doesn't matter, if you solve this with SpamAssassin or perl 
code. Use that what you can maintain better.

> When I call SA from within my MIMEDefang filter, I'll split the return
> list of matched rules and check them against a hash table of known
> journal tags.  If one of the tags on a message is in the table, then
> mimedefang will add two new headers to the message: "X-TOC: true" and
> "Keywords: JPhysChem" (for example).  The actual keyword will be the

You will have to remove those headers for other messages, so that "X-TOC: 
true" cannot be injected from the outside.

> We run a cyrus imap system with server side filtering performed by
> sieve.  The librarian's sieve script will detect messages with the
> X-TOC header and redirect them to the GNU Mailman mailing list.
> Mailman will then use the Keywords field to determine who wants that
> TOC alert based on its topics list.

I don't know if Mailman can act upon keywords as you describe, maybe you 
need to redirect the messages to the particular list, e.g. directly to 
JPhysChem at mailman.host

If cyrus allows to access messages in one mail folder through a script and 
your users accept some latency, I would use another method:

1) Sieve files all tagged messages into one mail folder, say "articles".

2) via cron a script scans "articles", extracts and removes each message 
from there.

3) each message is injected into Mailman via command line, maybe you can 
mangle each message before, e.g. with:



/var/lib/mailman/mail/mailman post list_name

If you setup a complete new mailbox for these messages or can use 
sub-addressing (librarian+maillist at ...) you could drop the tagging 
completely and perform the check after accepting the messages.

> Now, does this sound reasonable, or is it too complex?  What is the
> best way to import the necessary hash tables into my
> mimedefang-filter?  Is there a simpler way to achieve the same effect?

Do you use some external database / service already? Otherwise, replacing 
the filer and reloading it works well.

> It occurs to me that each of these messages will pass through the
> system twice with my current technique.  I could bypass the analysis
> with previously tagged message, or perhaps I should have mimedefang
> change the recipient of the tagged messages?

About changing the recipient:
Technically you can do this, you would need to configure Mailman to accept 
mails "not to the list", because the mailing list is not part of the "to" 
header and maybe the recipient list is larger than the threshold 
configured in the list, and you cannot strip personal / administrative 
data from the messages. For instance, maybe the messages contain 
unsubscribe links and you might want to make sure, that replies - either 
by human or DSNs - are not returned to the article origin.


In short, I would suggest to setup a mail folder (or INBOX of another 
mailbox) for these messages only, parse them via cron script, remove most 
headers and patch return and recipient addresses, and inject them to 
mailman via command line. The librarian should check this folder for 
unhandlable messages now and then.


- -- 
Steffen Kaiser
Version: GnuPG v1.4.6 (GNU/Linux)


More information about the MIMEDefang mailing list