Php 使用dompdf发送邮件

Php 使用dompdf发送邮件,php,dompdf,Php,Dompdf,可能重复: 我想在生成PDF后立即发送电子邮件。 我有一本书。dompdf和phpver5.2的dompdf_0-6-0_beta3。能够根据需要生成PDF。但是有谁能帮我发送带有生成的pdf作为附件的邮件吗 这就是我在申请表中所做的,请仔细阅读,如果您有任何疑问,请告诉我 我假设你可以通过你的申请发送邮件 $pdf = $dompdf->output(); $file_location is the path where you saved your pdf file in your

可能重复:

我想在生成PDF后立即发送电子邮件。
我有一本书。dompdf和phpver5.2的dompdf_0-6-0_beta3。能够根据需要生成PDF。但是有谁能帮我发送带有生成的pdf作为附件的邮件吗

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

我假设你可以通过你的申请发送邮件

$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());
       }

     }

现在编写一个邮件功能,就像我在评论中提到的那样。

到目前为止,您实现了多少?您是否能够在系统中生成并保存pdf?请显示您的代码并在您的问题中添加更多描述。你好,Rikesh,是的,我可以在我的系统上保存生成的PDF。我在我的应用程序中也做了同样的事情………您是在服务器上还是在本地主机上做这件事…@Alphamate,谢谢,只需通过该链接,干杯:)@venky,它在本地主机上正在尝试!!