Welcome Guest, Not a member yet? Register   Sign In
E-mail pdf document before saving in a folder

I have the following code which generates a pdf certificate and saves it in a folder. 

$this->data['html'] = $html;

$filename = $userid;
$pdfFilePath = FCPATH."assets/downloads/reports/".$filename.".pdf";

$data['page_title'] = 'Certificate'; // pass data to the view
if (file_exists($pdfFilePath) == FALSE) {
    $pdf = $this->pdf->load();
$pdf->WriteHTML($html); // write the HTML into the PDF
$pdf->Output($pdfFilePath, 'F'); // save to file because we can
else {
echo "Some problem is their, please contact admin regarding this..";
$this->load->view('certificate', $this->data);

However, I would like to send the same certificate after generation through e-mail to a recipient. What do I need to do?



However, I would

You can have another function call before redirect that handles email such as
$this->sendEmail($from,$to,$path_to_pdf); //you can set your require pass in params, just rough suggestion

Look at email helper and see how it attaches the file Or you can have your own email class

My project involved lot of pdf generations and auto deliveries so that is one of the methods

Theme © iAndrew 2016 - Forum software by © MyBB