Sending a mime encoded attachment really isn't rough. Have you sent emails with PHP before? (if not, check out [man]mail[/man])
$emailto = '[email address goes here]';
$subject = 'Subject';
$header = "From: $from <$fromemail>\n";
$header .= "Reply-To: $from <$fromemail>\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=\"MIME_BOUNDRY\"\n";
$header .= "X-Sender: $from <$fromemail>\n";
$header .= "X-Mailer: PHP4\n";
$header .= "X-Priority: 3\n";
$header .= "Return-Path: <$fromemail>\n";
$header .= "This is a multi-part message in MIME format.\n";
$message = ReadTemplate('email');
$data['message'] = 'A file has been attached.' . "\n\n--\nThis is an automated email message.";
$data['contenttype'] = 'application/octetstream';
$data['filename'] = $files[$key]['name'];
$data['attachment'] = BuildAttachment($destFile);
$message = ParseTemp($message, $data, "null");
mail($emailto, $subject, $message, $header);
And BuildAttachment() looks like:
function BuildAttachment($file)
{
set_magic_quotes_runtime(0);
$fd = fopen($file, "rb");
$FileContent = fread($fd, filesize($file));
fclose($fd);
$FileContent = chunk_split(base64_encode($FileContent));
$attachment = $FileContent;
$attachment .="\n\n";
set_magic_quotes_runtime(get_magic_quotes_gpc());
return $attachment;
} // end function BuildAttachment($filename)
The email template I use:
--MIME_BOUNDRY
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!--$message$-->
--MIME_BOUNDRY
Content-Type: <!--$contenttype$-->; name="<!--$filename$-->"
Content-disposition: attachment
Content-Transfer-Encoding: base64
<!--$attachment$-->
--MIME_BOUNDRY--
You will find some variables in there you'll need to swap out (like $file, $fromemail, etc). You'll see an array called $data and its setup to work with my template functions. The data it contains get swapped in for the tokens found in the email template. You can pull that stuff out and manually build your email and that will work fine too (you can see in the template where the data in $data would go).