Send FPDF document with PHPMailer;

旧时模样 提交于 2019-12-03 08:25:40

You just need to fix your permissions. If FPDF can't write the file, then there's nothing for PHPMailer to send, so of course it won't work.

Alternatively you can render to a string and attach that instead - this way it doesn't need to write a file:

$pdfdoc = $pdf->Output('', 'S');
...
$mail->addStringAttachment($pdfdoc, 'my-doc.pdf');

If you need to save file and send, use this.

   $file = basename("test");    //create file
    $file .= '.pdf';    //change extension of file to .pdf
    $pdf->Output($file, 'F');   //save file
  ..... 
    $mail->AddAttachment("test.pdf");   //add attachment

take care of file location.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!