Mimicry - A Mail Post Processor
What it is and can do
- Programmed in perl
- A daemon that receives and sends mails via SMTP
- A program to inspect and manipulate mail parts (mime entities)
within an SMTP flow
- Easily extendable by outsourcing the actual processing to plugins that get loaded during startup
- Coded with flexibility in mind
- Filterspecification with perl regular expressions
- A configuration file where you can specify lists of actions to be
executed on mail parts, based on
- (envelope) sender and recipient
- mime type and path of mime types from top level entity to
inspected entity
- recommended filenames
- and (to a certain extent) the position of the part within the mails mime tree
- And of course: licensed under the GPL
What it isn't and can't do
- A content scanner (for spam, virii and other malware)
Rationale
A client required a program that could add disclaimers to mails, as well
as compress attachments of outbound mail on the fly. Looking around, I
saw that there seemed to be a lack of an open source mail post processor...
While there were (a few)
programs out there that could do disclaiming, they all lacked flexibility,
most weren't open source, and most (if not all) were programs that were
invoked over files, and couldn't talk SMTP on their own - requiring each
mail to be stored in a file outside the mail queue, have the disclaimer
program invoked and then having to reinject the processed mail into the
mail stream. While not much of problem for a few hundred or thousand mails
a day, imagine running something like that on a big scale - say dozends or
hundreds of mails a second on a mailserver that is already io-bound. I
don't know if mimicry is already better than that, but the aim is to be
significantly better.
As for the second requirement, I found absolutely nothing with google or
freshmeat that would fulfill that need. So I went about writing this
program to fill that gap.
Currently implemented Plugins
- IgnoreMail - pass mail on unmodified
- Keep - keeps mail (mime) parts unmodified
- Disclaim - Appends a text to mail (mime) parts
- Zip - Compress attachments into one zip file attachment
Changes since 0.3
- Added size filters for the entire mail and individual mail parts
- Added header sender and header recipient filters
- Each rule now has its own plugin instance, making certain
multi-domain setups possible (e.g. different disclaimers for different
domains)
Todo
- Add generic mail header filters (for Subject:, ... )
- Switch to pre-forking server model
- Add negations for filters
- Add true multi-domain capabilities, based on the policy banks model
in amavisd-new
- Maybe add LMTP and unix domain socket transports
- Future plugins planned:
- TarGzip, TarBzip2 - alternatives to Zip
- Remove - explicitely Remove and drop mailparts from a
mail
- Archive(???) - copy mails passing through to the local
filesystem (strangely, lots of companies want to know what
employees are writing each other...)
- PGP/GPG(???) - sign and/or encrypt Mails on the fly (to
compensate for Archive, if I ever implement it)
- ... whatever kind of requirements pop up in the future
Caveats
My knowledge of mime isn't the best, so I won't put it beyond myself that
there are some subtle bugs regarding mime handling in code.
- I still consider the code to be beta, until it has experienced a
wider testing base
- The process is prone to dying if the sending mail server goes away
before we can confirm the receipt of data
- Single-part and non-mime messages are currently always translated
into a multi-part mime message with the original message as the first
subentity
- Currently mimicry uses a non-forking network model, so expensive
rules could cause a mailqueue to back up...
Requirements
You will need the following perl modules:
- Unix::Syslog
- Net::Server::Mail::SMTP
- Net::SMTP
- MIME::Tools
Download
Contact, praise, criticism, bug reports, patches, new modules, ...
sr@baghus.net
Links
- Baghus GmbH - My employer. A
german company offering an open source based spam and malware mail
scanner appliance with commercial support
- Amavisd-new - if you need a content scanner, this is the place to go
Thanks
- Mark Martinec, who is the maintainer and author of amavisd-new. I've
gotten a few design ideas and inspirations from the way amavisd-new is
configured and handles mail
- David F. Skoll, current maintainer of MIME::Tools for clearing up a
few questions for me
- My boss for letting me release this code as open source
|