Can someone help me out please!
I've been struggling with trying to attach a pdf file to a mail() function. I've been using MIME with no luck.
I'm using a pdf creator found at www.ros.co.nz/pdf and can create wonderful dynamic pdf files. I can "output" the results and produce the actual file on my computer (I can load this pdf file perfectly). My next step is to use MIME to attach it to the e-mail but everything gets corrupted and does not open.
I'm totally frusterated! I can send html, txt, etc, but not pdf. I heard MIME has to be set up perfectly but can't find my error.
Here is my current MIME code:
$filename = "report.pdf";
$boundary = md5(uniqid(time()));
$head .= "MIME-Version: 1.0\r\n";
$head .= "Content-type: multipart/mixed; boundary=\"$boundary\"\r\n\r\n";
$head .= "This is a multi-part message in MIME format.\r\n\r\n";
$file = BuildAttachment($report);
$bod = "--$boundary\r\n";
$bod .= "Content-type: application/pdf;charset=$mail_charset\r\n";
$bod .= "Content-transfer-encoding:$mail_encoding\r\n\r\n";
$bod .= "$body\r\n";
$bod .= "--$boundary\r\n";
$bod .= "Content-type:application/pdf; name=\"$filename\"\r\n";
$bod .= "Content-transfer-encoding:base64\r\n\r\n";
$bod .= "Content-disposition: attachment; filename=\"$filename\"\r\n";
$bod .= $file."\r\n\r\n";
$bod .= "--$boundary--";
$body = $bod;
I would really appreciate a little advice! If the above code makes no sense, I'll post my entire code if you like.