dongnai1876 2015-03-19 17:48
浏览 53

在Aol电子邮件中发送电子邮件中的pdf附件

I am sending a pdf attachment within an email and am having an issue when trying to be opened in Aol mail. The attachment showing like on email abc.pdf (< 1 KB).The attachment says:

Adobe Reader could not open'abc.pdf' because it is either not a supported file type or because the file has been damaged(for example, it was sent as an email attachement and wasn't correctly decoded).

Here is my code:

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 = "
";
$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 
"
      ."MIME-Version: 1.0
"
      ."Content-Type: multipart/mixed; boundary=\"".$uid."\"

"
      ."This is a multi-part message in MIME format.
" 
      ."--".$uid."
"
      ."Content-type:text/plain; charset=iso-8859-1
"
      ."Content-Transfer-Encoding: 7bit

"
      .$message." 
      ".$companyinfo."

"
      ."--".$uid."
"
      ."Content-Type: application/octet-stream; name=\"".$filename."\"
"
      ."Content-Transfer-Encoding: base64
"
      ."Content-Disposition: attachment; filename=\"".$filename."\"

"
      .$content."

"
      ."--".$uid."--";

Any Suggestions please.

  • 写回答

1条回答 默认 最新

  • doumao1917 2015-03-19 21:16
    关注

    Try to define your headers in he string $headers like that :

        'Content-Type: application/pdf';
        'Content-Disposition: inline; filename="'.$filename.'"';
            'Cache-Control: private, max-age=0, must-revalidate';
        'Pragma: public';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序