【发布时间】:2023-03-04 14:15:01
【问题描述】:
在我看来,我一直在尝试发送带有pdf 附件的电子邮件,该附件由MPDF 库在codeigniter 中生成,我已成功将我的文件转换为PDF,或者我认为我做到了,但我找不到任何方法使用 CodeIgniter 中的给定功能将该文件附加到电子邮件。
在 CodeIgnitor 的文档中,attach 函数的一个令人困惑且不完整的描述暗示了这一点:
$this->email->attach($buffer, '附件', 'report.pdf', '应用程序/pdf');
$buffer 是字符串,report.pdf 是电子邮件附件的文件名,
现在我关心的是我可以附加我生成的视图,如下所示:
ini_set('memory_limit', '20M');
// load library
$this->load->library('pdf');
$pdf = $this->pdf->load();
// boost the memory limit if it's low ;)
$html = $this->load->view('reports/someReport', array('var' => 123), true);
// render the view into HTML
$pdf->WriteHTML($html);
$this->email->attach($pdf->Output('', 'S'), 'attachment', 'report.pdf', 'application/pdf'); // is this okay or something is wrong here ?
我怎样才能成功地用电子邮件附加它并发送它
【问题讨论】:
标签: php codeigniter email pdf