CodeIgniter Forums

Full Version: E-mail pdf document before saving in a folder
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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