【发布时间】:2015-11-20 15:56:36
【问题描述】:
我目前正在尝试使用 FPDF 生成 pdf,然后使用 PHPMailer 将其发送到电子邮件中。我知道 PHPMailer 功能正在运行,我可以创建 pdf。但是当我尝试先将pdf下载到服务器时,输出($pdf,“F”),我得到了错误:
警告 (2): fopen(/temp-file.pdf): 无法打开流: 权限被拒绝 [APP/Vendor/fpdf/fpdf.php, line 1025]FPDF 错误: 无法创建输出文件: /temp -file.pdf
pdf 的创建很长,所以我将向您展示我尝试输出它的过程。
FPDF
$pdfoutputfile = 'temp-folder/temp-file.pdf';
$pdfdoc = $pdf->Output($pdfoutputfile, 'F');
PHPMailer
$mail = new phpmailer;
$mail->SetFrom("info@company.com","Company");
$mail->AddAddress($to);
$mail->Subject = "Invoice $id";
$body .= "This is an automatically generated message from Company \n";
$mail->Body = $body;
$mail->AddAttachment($pdfoutputfile, 'my-doc.pdf');
if(!$mail->Send()) {
$this->Session->setFlash("Invoice was not sent");
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
$this->Session->setFlash("Invoice was sent");
}
有人可以帮我解决吗? 谢谢!
【问题讨论】:
-
这是另一个已回答的问题,可能会对您有所帮助。 stackoverflow.com/questions/4353271/…
-
停止错误但 pdf 不与电子邮件一起发送