back to the  M I V O !  site

MIVA®  RESOURCES: Mimeconv (e-mail attachments)

program written by Nobby N Hirano

Updated 9/8/2000

MimeConv 2.0 available - read the description !

Mimeconv encodes binary files for sending by SMTP and decodes e-mail attachments back to binaries. Program was tested under Linux, HP-UX and MS-Windows95/NT. Mimeconv is free software. See the 'LICENSE' file for the details.

Mimeconv is a tiny but performant program. It is able to encode/decode huge files in very short time.

download (binaries and C sources - 30kB)

How to use Mimeconv with Miva®

I did not find any way to call the Mimeconv binary with its arguments directly from Miva. Maybe there is a way but I use a small Perl script (mimeconv.pl) as a gateway:

#!/usr/bin/perl

$prg = 'path_to_the_mimeconv_binary';
$dir = 'path_to_your_data_directory';

@pairs = split(/&/, $ENV{'QUERY_STRING'}); # Split the name-value pairs
local($name, $value) = split(/=/, $pairs[0]);
print "Content-Type: text/plain\n\n";

if ($name eq 'd') 
 {system ($prg.' -C '.$dir.' -d '.$dir.$value.' > /TMP');}
else 
 {
  if ($name eq 'e') 
   {
    system ($prg.' -e '.$dir.$value.' > /TMP');
    open(TMP, '/TMP'); while () {print $_;} close (TMP);
   }
  else {print "missing or bad argument";}
 }

Converting e-mail attachments into binaries (receive):

  <MvPOP MAILHOST=...>
    <MvCALL ACTION="URL_of_mimeconv.pl?d=&[messagebody];" METHOD="GET">
  </MvPOP>
 

Converting binaries into e-mail attachments (send):


<MvASSIGN name="l.fileName" value="name_of_the_file_to_attach">
<MvASSIGN name="l.boundary" value="{'----=_NextPart_' $ random(673567) crypt random(78)}">
<MvSMTP ...>
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="&[l.boundary];"
This is a multi-part message in MIME format.

--&[l.boundary];
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

TEXT OF YOUR MESSAGE COMES HERE

--&[l.boundary];
Content-Type: application/octet-stream;
	name="&[l.fileName];
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="&[l.fileName];

<MvCALL ACTION="URL_of_mimeconv.pl?e=&[l.fileName];" METHOD="GET">
<MvEVAL EXPR="{callvalue}">
</MvCALL>
--&[l.boundary];--
</MvSMTP>
 

top


Miva and some other terms used on this page are registerd trademarks of the Miva Corporation
copyright  truXoft  © 1997-2010