I try to send an email from my server to recipient, no problem, the email is sent. I have TEXT HTML in this email, and a PDF attachment...
The problem is: I receive the mail, I receive the PDF, but there is NO text!
Here is my code if you can help :)
$filepath = '../../path/file.pdf';
if (!preg_match("#^[a-z0-9._-]+@(hotmail|live|msn).[a-z]{2,4}$#", $email))
{
$br = "\r\n";
}
else
{
$br = "\n";
}
$message_html= "Content-Type: text/html; charset=\"ISO-8859-1\"".$br;
$message_html.= "Content-Transfer-Encoding: 8bit".$br;
$message_html.= '<!DOCTYPE html><html><head>
<title>mytitle</title>
</head>
<body>
<div>
my content!
</div
</body>
</html>';
$boundary = "-----=".md5(rand());
$boundary_alt = "-----=".md5(rand());
$subject = "mysubject";
$attached_file = file_get_contents($filepath);
$attached_file = chunk_split(base64_encode($attached_file));
$pos=strrpos($filepath,"/");
if($pos!==false)$file_name=substr($filepath,$pos+1);
else $file_name=$filepath;
$pos=strrpos($filepath,".");
if($pos!==false)$file_type="/".substr($filepath,$pos+1);
else $file_type="";
$attached = "\n\n". "--" .$boundary . "\nContent-Type: application".$file_type."; name=\"$file_name\"\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment; filename=\"tickets.pdf\"\r\n\n".$attached_file . "--" . $boundary . "--";
//=====HEADER
$header = "To: ".$email." ".$br;
$header.= "From: frrrrrom".$br;
$header.= "Cc: cccccccc".$br;
$header.= "Reply-to: qdfqsf".$br;
$header.= "MIME-Version: 1.0".$br;
$header.= "Content-Type: multipart/mixed;".$br." boundary=\"$boundary\"".$br;
//==========
$body = $message_html.$attached;
mail($email,$subject,$body,$header);