[Mimedefang] Is this possible w/ MIMEDefang?

Stefan Schoeman stefan at internext.co.za
Sat Oct 8 19:36:03 EDT 2005

Garry Glendown wrote:

> Can MIMEDefang :

> - quarantine large files for admin approval (e.g., forwarding to an
> admin account, with an extra header containing the original recipients)

Yes, quite easily. MIMEDefang dumps the original unaltered mail in a file 
named INPUTMSG and you can easily check its size through something like :

  $xsize = (-s "./INPUTMSG");
  if ($xsize > $quarantinesize) {
    Your quarantine actions in here.

In that "Your qurantine actions in here" you would delete all recipients, 
add the original recipient list to a custom header and add the approver's 
email address. There are standard MIMEDefang functions for adding and 
deleting recipients, as  well as writing custom headers. For me though, it 
works nicer to copy the INPUTMSG file to another location and enter a record 
of it into a database. I then have a simple web application that lists the 
quarantined mailes with a set of release and reject radio buttons for each 
record. The approver's job now just becomes to go to this page and to select 
which emails to approve and which to reject.

> - quarantine certain file types for admin approval (dito)

As one of the original features (if not THE primary feature) of MIMEDefang 
was to strip away certain filetypes, this is quite easy to do. Instread of 
letting MIMEDefang strip the attachments, just mark that the entire message 
should be quarantined later in your script. So in the pseudo-snippet above, 
the criterion of the filesize is just altered to also check whether the mail 
was previously flagged to quarantine mails with certain file attachments.

> - limit number of recipients, mails exceeding the number would be
> quarantined again

Again, very easy - just inspect the number of elements in the MIMEDefang 
@Recipients array, i.e something like
  if (scalar @Recipients > 20) { Quarantine(); }

Of course, all the stuff above would need to be done by modifying the 
mimedefang-filter perl snippet. But it isn't rocket science and is rather 
simple even if you are a real amateur perl programmer, like me ;)

Basically, one can really see MIMEDefang as an extremely convenient 
mechanism for taking programmatic control of anything to do with mail. The 
stripping of unsafe attachments, virus scanning and spam filtering is nice, 
but for me its real coolness comes because even an elementary perl 
programmer can suddenly do pretty amazing stuff with mail.

Give me a shout if you need help customising your mimedefang-filter, 
although there are a large number of people on this list that could probably 
do it much better than I could ;)


More information about the MIMEDefang mailing list