[Mimedefang] URLing multimedia attachments

Yizhar Hurwitz yizhar at mail.com
Sat Mar 4 15:57:23 EST 2006


HI.

Matthew S. Cramer wrote:
> Indeed.  In a week we are implementing a feature to remove multimedia
> files from emails using MIMEDefang and replace them with a URI and
> some scare text to say "click here to get your media file, and be sure
> you are complying with our acceptable use policy."

I have implemented this on my MD machine and would like to share the 
code I used, especially the list of extensions in use.
I also do the same with files over a specific size (8MB), but these are 
stored in different location.
This is what I have in "sub filter":

################################

   $size = (stat($entity->bodyhandle->path))[7];
   if ($size > 8000000) {
       return action_replace_with_url($entity,
       "/var/www/mimedefang/bigfiles",
       "http://x.x.x.x/bigfiles",
       "\nThe attached file was larger then 8MB.\n" .
       "You can download it from the following URL:\n\n" .
       "_URL_\n\n" .
       "The original file name is:\n" . $fname . "\n\n" .
       "File Size = " . $size . "\n\n" .
       "Please note that the download process can take a long time.\n" .
       "Please note that the file will later be deleted from the mail 
server.\n"
       );
   }

   $multimedia = '(asf|avi|mov|mpeg|mpg|wmv)';
   if (re_match($entity,'\.' . $multimedia)) {
       return action_replace_with_url($entity,
       "/var/www/mimedefang/multimedia",
       "http://x.x.x.x/multimedia",
       "\nThe attached multimedia file is available for download 
here:\n\n" .
       "_URL_\n\n" .
       "Original file name:\n" . $fname . "\n\n" .
       "File Size = " . $size . "\n\n" .
       "Please note that the file will later be deleted from the mail 
server.\n"
       );

################################

I currently have no statistics about this, but I can tell that it was 
implemented 4 months ago
and I didn't got any complain or query from the users about this filter.
I haven't yet implemented a script to delete old files from there 
because it currently doesn't take too much disk space.
You can consider doing the same with PPS and maybe other extensions.

FYI

Yizhar Hurwitz
http://yizhar.mvps.org





More information about the MIMEDefang mailing list