【问题标题】:Sending mail using dompdf [duplicate]使用 dompdf 发送邮件 [重复]
【发布时间】:2013-01-31 07:02:18
【问题描述】:

可能重复:
DOMPDF - attach created PDF to email

我想在 PDF 生成后立即发送电子邮件。 有版本。 DOMPDF 的 dompdf_0-6-0_beta3 和 php ver 5.2 。能够根据需要生成PDF。但是任何人都可以帮助我如何发送带有生成的pdf作为附件的邮件。

【问题讨论】:

  • 到目前为止,您取得了多少成就?你能在你的系统中生成并保存你的 pdf 吗?请显示您的代码并在您的问题中添加更多描述。
  • 嗨 Rikesh,是的,我可以将生成的 pdf 文件保存在我的系统上
  • 我在我的应用程序中做了同样的事情............你是在服务器还是本地主机......
  • @Alphamate,谢谢,通过那个链接,干杯:)
  • @venky,它在本地主机上正在尝试!!

标签: php dompdf


【解决方案1】:

这是我在申请中所做的,请仔细阅读,如果您有任何疑问,请告诉我。

我假设您可以从您的应用程序发送邮件。

$pdf = $dompdf->output();
$file_location is the path where you saved your pdf file in your local host.
file_put_contents($file_location,$pdf);

Now call your mail function like this.
sendMail($from,$to,$subject,$message,$file_location);

       function sendMail()
      {
       $config = Array(
                'protocol' => 'smtp',
                'smtp_host' => 'ssl://smtp.googlemail.com',
                'smtp_port' => 465,
                'smtp_user' => 'xxx@gmail.com', // change it to yours
                'smtp_pass' => 'xxx', // change it to yours
                'mailtype' => 'html',
                'charset' => 'iso-8859-1',
                'wordwrap' => TRUE
               );


       $this->load->library('email', $config);
       $this->email->set_newline("\r\n");
       $this->email->from($from); // change it to yours
       $this->email->to($to);// change it to yours
       $this->email->subject($subject);
       $this->email->message($message);
       $this->email->attach($file_location);
       if($this->email->send())
       {
          echo 'Email sent.';
       }
       else
       {
          show_error($this->email->print_debugger());
       }

     }

现在写一个我在 cmets 中提到的邮件函数。

【讨论】:

    猜你喜欢
    • 2012-09-11
    • 2012-05-01
    • 2018-06-27
    • 2018-03-26
    • 1970-01-01
    • 1970-01-01
    • 2016-05-10
    • 2012-03-22
    • 2015-12-10
    相关资源
    最近更新 更多