DOMPDF - 将创建的PDF附加到电子邮件 [英] DOMPDF - attach created PDF to email

查看:179
本文介绍了DOMPDF - 将创建的PDF附加到电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过DOMPDF将PDF附加到电子邮件中最简单的方法是什么?

What is the easiest way to attach a PDF to an email via DOMPDF?

我正在使用的脚本(其中一部分)的结尾如下: / p>

The end of my script I am using (part of it) is below:

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();    
//below to save the pdf file - not needed if emailing pdf
file_put_contents('/home/ststrave/public_html/pdf/STS_Brochure.pdf', $dompdf->output());
//below to open pdf in browser - required
$dompdf->stream("STS_Brochure_".rand(10,1000).".pdf", array("Attachment" => false));
jexit();

只是为了澄清 - 这是在Joomla中使用。

Just for clarification - this is being used in Joomla.

使用标准PHP邮件功能欣赏最简单/最快捷的方式。

Appreciate the simplest/quickest way using standard PHP mail function.

干杯; - )

推荐答案

PHP的邮件功能没有标准文件附件方法。这是一个非常准确的SMTP系统接口,强制您自己完成附加文件的所有工作。

PHP's mail function has no "standard" file attachment method. It's an extremely barebones interface to the SMTP system that forces you to do ALL the work of attaching a file yourself.

我强烈建议使用 PHPMailer Swiftmailer 为您发送电子邮件 - 它减少了生成您自己的MIME邮箱和插入附件(许多行代码)的繁重工作,总共可能有5行。

I strongly suggest using PHPMailer or Swiftmailer to do the email for you - it reduces the heavy grunt work of generating your own MIME email and inserting the attachment (many many lines of code) does to maybe 5 lines total.

请注意,将处理DOMPDF的流式PDF。您必须将PDF保存到临时文件,并附加

Note that neither of them will handle a streamed PDF from DOMPDF. You'll have to save the PDF to a temporary file and attach that,

这篇关于DOMPDF - 将创建的PDF附加到电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆