Problem with attaching pdf to email and sending
Posted: Thu Apr 21, 2005 10:33 am
Does anyone know why this is not working:
Basically, I am trying to attach a pdf to an email and send it. The file sends but there is no attachment and no message in the body of the email.
Thanks!
Code: Select all
// Send email to complete the order with WorkoutSupplies.com
$boundary = '-----=' . md5( uniqid ( rand() ) );
$len = filesize("/home/seekshop/public_html/fitness/invoices/".$HTTP_GET_VARS['oID'].".pdf");
$type = filetype("/home/seekshop/public_html/fitness/invoices/".$HTTP_GET_VARS['oID'].".pdf");
$message .= "Content-Type: application/$type; name=\"".$HTTP_GET_VARS['oID'].".pdf\"\n";
$message .= "Content-Length: $len";
$message .= "Content-Disposition: attachment; filename=\"".$HTTP_GET_VARS['oID'].".pdf\"\n\n";
$path = "/home/seekshop/public_html/fitness/invoices/".$HTTP_GET_VARS['oID'].".pdf";
$fp = fopen($path, 'r');
do //we loop until there is no data left
{
$data = fread($fp, 8192);
if (strlen($data) == 0) break;
$content .= $data;
} while (true);
$content_encode = chunk_split(base64_encode($content));
$message .= $content_encode . "\n";
$message .= "--" . $boundary . "\n";
$message_body = "Please ship the attached order for SeekShopping.com Fitness";
$headers = "From: \"SeekShopping.com Fitness\"<seekshop@seekshopping.com>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
mail('seekshop@seekshopping.com, mattmcb123@yahoo.com', 'URGENT: DROPSHIP ORDER FROM SeekShopping.com Fitness ENCLOSED', $message . $message_body, $headers);Thanks!