CodeIgniter Forums
E-mail pdf document before saving in a folder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: E-mail pdf document before saving in a folder (/thread-69038.html)



E-mail pdf document before saving in a folder - cndunga - 09-29-2017

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
unlink($pdfFilePath); 
if (file_exists($pdfFilePath) == FALSE) {
    ini_set('memory_limit','32M'); 
$this->load->library('pdf');
    $pdf = $this->pdf->load();
    $pdf->SetFooter($_SERVER['HTTP_HOST'].'|{PAGENO}|'.date(DATE_RFC822)); 
$pdf->WriteHTML($html); // write the HTML into the PDF
$pdf->Output($pdfFilePath, 'F'); // save to file because we can
redirect("assets/downloads/reports/$filename.pdf"); 
}
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?

Regards

Charles

However, I would


RE: E-mail pdf document before saving in a folder - ciadvantage - 09-29-2017

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