[Mimedefang] Idea: using action_replace_wiht_url for file transfer

Andrew J Caird andrew.caird at fccc.edu
Thu Jan 15 09:47:59 EST 2004


JOna,
  The Mimedefang HowTo has an example of almost exactly this.  At
http://www.rudolphtire.com/mimedefang-howto/ search for
action_replace_with_url and read that part of the document (portions
reproduced below).
  Hope this helps.
--
Andrew Caird            andrew.caird at fccc.edu               215.728.4071
Email Administrator                              Fox Chase Cancer Center

---------------------------------------------------------------------------
Extracted from above mentioned page:

This action is intended for stripping large parts out of the message and
replacing them to a link on a Web server. Here's how you would use it in
filter():

$size = (stat($entity->bodyhandle->path))[7];
if ($size > 1000000) {
     action_replace_with_url($entity,
          "/home/httpd/html/mail_parts",
          "http://mailserver.company.com/mail_parts",
          "The attachment was larger than 1,000,000 bytes.\n" .
          "It was removed, but may be accessed at this URL:\n\n" .
          "\t_URL_\n");
}

This example moves attachments greater than 1,000,000 bytes into
/home/httpd/html/mail_parts and replaces them with a link. The directory
should be accessible via a Web server at
http://mailserver.company.com/mail_parts.

The generated name is created by performing a SHA1 hash of the part and
adding the extension to the ASCII-HEX representation of the hash. If many
different e-mails are sent containing an identical large part, only one
copy of the part is stored, regardless of the number of senders or
recipients.
---------------------------------------------------------------------------

On Thu, 15 Jan 2004, JOna wrote:

> Hi,
>    We often need to transfer large files to people who's mailbox-quota
> is limited. For regular transfers I have made ftp-accounts, but that is
> not allways an option: many people just WANT to use email for file
> transfer, and there's no point in creating temporary ftp-account for a
> every single file transfer (and then having to teach on phone to someone
> in the other side of the country how to install and use the ftp-client
> programm).
>
> So I've come to think a new idea: whyt not use MIMEDefang's
> action_replace_wiht_url to create a email + web-based file transfer
> system that works with commands on Subject-line. Something like this:
>
> Create mimedefang-filter that checks for a "magic word" in Subject-line
> and when it is found, does the following:
>
> 1) Create a hash of the first attachement (or all the attachements)
> 2) Create a web-accessible directory named with this hash.
> 3) Copy all the attachements to this directory, preserving the original
> filenames (This is important!)
> 4) Replace attachements with url http://webserver.com/hash/
> 5) Remove "magic word" from the Subject-line
>
> Example:
>
> I want to send a 30MB file to jsmith at company.com, whose mailbox is only 2MB.
> Now I send the file as attachement, if I add [magic] to Subject line:
>        Subject: [magic] Here's the project data
>
> John Smith then receives a (tiny) message
>        From: me at company.com
>        Subject: Here's the project data
>        Message:
>
>        Hi,
>
>        you will find the files from the following address:
>        http://webserver.com/dh34hs45fbikjomeociw/
>
>
> But how to do this? I have tested only the "standard" filter that
> measures the size of the attachement:
>
> #  Save HUGE attachements to webserver
>    $size = (stat($entity->bodyhandle->path))[7];
>       if ($size > 1000000) {
>          return action_replace_with_url($entity,
>          "/var/www/webserver.com/attachements",
>          "http://webserver.com/attachements",
>          "message...\n" .
>          "_URL_\n\n");
>       }
>
> With my limited programming skills I can't modify the script myself, so
> I just throw the idea here and hope that someone grabs it :-)
>
> JOna



More information about the MIMEDefang mailing list