我在电子邮件中发送pdf附件,并且在尝试在Aol邮件中打开时遇到问题。附件显示在电子邮件abc.pdf(< 1 KB)上。附件说:
Adobe Reader无法打开' abc.pdf'因为它不是一个 支持的文件类型或因为文件已损坏(例如, 它是作为电子邮件附件发送的,并未正确解码。
这是我的代码:
include("walljs/mpdf/mpdf.php");
$mpdf=new mPDF();
$mpdf->ignore_invalid_utf8 = true;
$stylesheet = file_get_contents('appstyle_pdf.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($output);
$comname = preg_replace("/[^A-Za-z0-9]/","",$_POST['company']);
$name = $dirname.str_replace(" ","-",$comname)."_".$time_stamp.".pdf";
$mpdf->Output($name,"F");
$file = $name;
$crlf = "\n";
$filename = basename($file);
$file_size = filesize($file);
$content = chunk_split(base64_encode(file_get_contents($file)));
$uid = md5(uniqid(time()));
$header = "From: orders@enkapps.com \r\n"
."MIME-Version: 1.0\r\n"
."Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"
."This is a multi-part message in MIME format.\r\n"
."--".$uid."\r\n"
."Content-type:text/plain; charset=iso-8859-1\r\n"
."Content-Transfer-Encoding: 7bit\r\n\r\n"
.$message."
".$companyinfo."\r\n\r\n"
."--".$uid."\r\n"
."Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"
."Content-Transfer-Encoding: base64\r\n"
."Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"
.$content."\r\n\r\n"
."--".$uid."--";
请提出任何建议。
答案 0 :(得分:0)
尝试在字符串$ header中定义标题:
'Content-Type: application/pdf';
'Content-Disposition: inline; filename="'.$filename.'"';
'Cache-Control: private, max-age=0, must-revalidate';
'Pragma: public';