[Mimedefang] Howto use mimidefang _only_ for replacing attachments with urls?

Paul Murphy Paul.Murphy at argentadiscovery.com
Wed Mar 14 07:43:32 EDT 2007

filter() is called for each part of the message, rather than for each attachment.  So, for example, a blank message with just a Word attachment will still have a text/plain part, and then an application/ms-word part or something similar.  For the plain text part, there may not be any body, so when you reference "bodyhandle" you will get an error.

Instead, check whether the file name has been set, and if so, you have an attachment, and can use the replace function.  If not, do nothing.  Something like:

(unchecked and untested code follows!)

sub filter ($$$$) {
    my($entity, $fname, $ext, $type) = @_;

if (defined($fname)) {
  $size = (stat($entity->bodyhandle->path))[7];
  if ($size > 1000000) {
     return action_replace_with_url($entity,
	  ($fname? "\"$fname\"" : "Attachment").
            " (".humanize($size).") relocated:\n\n_URL_",
    	 $fname  # extra data to save

Best Wishes,


Paul Murphy
Head of I.T.
Argenta Discovery
Tel. 01279 645 554
Fax. 01279 645 646

More information about the MIMEDefang mailing list