I am trying to take a recorded audio file (WAV) that was posted via a FORM and
send it via email and was wondering if this looked correct. This is a conversion of
this Perl unit:
http://cafe.bevocal.com/resources/v...endemail_pl.txt
<?php
$content = $_POST{"message"};
// ---------------------------------------------------------------------
// Construct the email message. The email message is of type
// "multipart-mixed" as there are two parts to it. The first part is
// a simple text meesage which forms the body of the e-mail.The second
// part is the attachment of the recorded data that was POSTED to this
// perl script.
// NOTE: change the From, To, Subject Fields below to reflect some valid
// addresses in your domain.
// ---------------------------------------------------------------------
// Create a MIME boundary
$boundary = '-----=' . md5( uniqid ( rand() ) );
// Modify these variable for your system
$from = "me\@myhost.com";
$to = "destination\@somecomany.com";
$subject = "Here's an audio email message for you";
$type = "multipart/mixed";
// ---------------------------------------------------------------------
// Construct the body of the email
// ---------------------------------------------------------------------
$message .= "Content-Type: text/plain;\"\n";
$message = "The enclosed file , audiofile.wav, was\n sent to you by the "
$message .= "Bevocal Cafe.\n Check us out at http://cafe.bevocal.com\n\n";
// not sure if this boundary is required here.
$message .= $boundary;
// ---------------------------------------------------------------------
// Attach the recorded wav file as an attachment to this email.
// ---------------------------------------------------------------------
$message .= "\nContent-Type: audio/wav'\n",
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: attachment; filename=\"audiofile.wav\"\n\n";
$content_encode = chunk_split(base64_encode($content));
$message .= $content_encode . "\n";
$message .= "--" . $boundary . "\n";
// ---------------------------------------------------------------------
// Send the email now. the 'send' method tries to send the email in the
// 'best-possible-manner'. By befault it uses sendmail.
//
// Change the paramters to your smpt server.
// ---------------------------------------------------------------------
$headers = "From: \"Me\"<$from>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\n";
mail($to, $subject, $message, $headers);
?>