0

Possible Duplicate:
DOMPDF - attach created PDF to email

I want to send an email instantaneously once PDF is generated. Have ver. dompdf_0-6-0_beta3 of DOMPDF and php ver 5.2 . Able to generate PDF as required. But can anyone please help me as how to send mail with generated pdf as attachment.

Community
  • 1
  • 1
Siddesh
  • 13
  • 6

1 Answers1

0

This is what i did in my application please go through it and if you have any doubts let me know.

I am assuming you can able to send mail from your application.

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

     }

Now write a mail function like i mentioned in the comments.

Venkata Krishna
  • 4,287
  • 6
  • 30
  • 53