bridawg, I was on holidays until now - this might be late, but I hope it can still help.
I ended up not sending a html attachment. I found that my carefully generated attachments where modified in too many email clients. Hotmail, Outlook, Mozilla, ... they all displayed the code differently. I ended up creating a pdf document: I ended up using http://www.ros.co.nz/pdf/.
As for the php code - here is what I used - you will have to look through it and modify it here and there of course.
<?php
$email = $_POST['mail_to'];
$check = checkmail($email);
if ($check) {
$message = send_mail($email);
header("Location: /view_results.php?message=$message");
exit;
}
else
$message = "Please enter valid e-mail address.";
function checkmail($address)
{
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $address))
return true;
else
return false;
} // function checkmail()
function send_mail($mail_to)
{
// Read POST request params into global vars
$to = $mail_to;
$from = "Report <report@me.com>";
$subject = "Report Completed";
$message = "";
// Obtain file vars
$fileatt = $type."_report.pdf";
$fileatt_type = "application/pdf";
$fileatt_name = $type."_report.pdf";
$headers = "From: $from";
$report = createReport();
$file = BuildAttachment($report);
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$file . "\n\n" .
"--{$mime_boundary}--\n";
// Send the message
if (@mail($to, $subject, $message, $headers))
return "Successfully sent report";
else
return "An unknown error occurred while attempting to send report";
} // function send_mail()
function BuildAttachment($string)
{
set_magic_quotes_runtime(0);
$FileContent = chunk_split(base64_encode($string));
$attachment = $FileContent;
$attachment .="\n\n";
set_magic_quotes_runtime(get_magic_quotes_gpc());
return $attachment;
} // function BuildAttachment()
function createReport()
{
include pdf_report.inc';
$report = $pdf->output();
return $report;
} // function createReport()
?>