我希望使用codeigniter在发送电子邮件中自动生成pdf附件

时间:2016-05-31 09:39:11

标签: codeigniter codeigniter-2 phpmailer

有人知道如何使用codeigniter和phpmailer自动生成自动生成的pdf然后,请帮助

$this->load->library('email');

$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@another-example.com');
$this->email->bcc('them@their-example.com');

$this->email->subject('Email Test');
$this->email->message('Testing the email class.');

$this->email->send();

1 个答案:

答案 0 :(得分:0)

你显然缺少几行代码......

我在生成这个代码后还包含了pdf的电子邮件:

$pdf = $this->generatePdf();
foreach ($pdf as $p)
    $this->email->attach('./barcodes/' . $p . '.pdf');

现在进行一些言论:

$pdf = $this->generatePdf();

这用于实际生成和存储pdf,结果将是一个包含实际pdf名称的数组。

foreach ($pdf as $p)
        $this->email->attach('./barcodes/' . $p . '.pdf');

用于遍历生成的pdf名称数组并实际包含它们,codeigniters电子邮件库具有attach功能,允许您添加附件。