I want to send a mail and attach a file which I get to click the download button of pdf?
//this the the PDF filename that user will get to download
$pdfFilePath = "$customer_name.'_'.$customer_phone.'_'.$time.pdf";
$this->user_model->update_order(['front_orders_id' => $id],['bill_pdf'=>$pdfFilePath]);
//load mPDF library
$this->load->library('m_pdf');
//generate the PDF from the given html
$this->m_pdf->pdf->WriteHTML($html);
//download it.
$this->m_pdf->pdf->Output($pdfFilePath, "D");
/*--------------------Mail function Start-----------------------*/
$order_fetch = $this->user_model->front_get_invoice_details(['front_orders_id' => $id]);
$email = $order_fetch[0]['customer_email'];
$pdf_name = $order_fetch[0]['bill_pdf'];
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'noreply@wsdev.in',
'smtp_pass' => '%KidFlash!2#4%',
'mailtype' => 'text/html',
'charset' => 'iso-8859-1',
'charset' => 'utf-8'
);
$this->load->library('email');
$this->email->set_mailtype("html");
$this->email->set_newline("
");
$from_email = 'noreply@wsdev.in';
$this->email->from($from_email);
$this->email->to($email);
$this->email->subject('Order Delivered');
$this->email->message('Your Order Successfully Delivered.');
$this->email->attach($pdfFilePath);
$this->email->send();
/*--------------------Mail Function End-----------------------*/
-This is my code. When I hit the download button, I want to download this page as a pdf and send as an attachment.