public function trigger_emails() { $sql = "select email from user where usertype_id=7 and status =1"; $res = $this->db->query($sql)->result_array(); $to = ""; foreach ($res as $key => $value) { $one = $value['email']; $to .= $one . ','; } $subject = 'Login Page Changes'; $message = "Dear All,<br/><br/> Please Note that the Login Page has been Changed to A National Data Page. However, on the top right hand corner of the page, is a link to Login.<br/> Please use that link to login to the system.<br/><br/><br/>Regards, <br/> Development Team"; $attach_file = null; $bcc_email = 'ttunduny@gmail.com,tngugi@clintonhealthaccess.org,annchemu@gmail.com'; // $receipient = array(); // $receipient =$to; //parse_str($_POST['receipients'], $receipient); //$receipient = $receipient['hidden-receipients']; include 'rtk_mailer.php'; $newmail = new rtk_mailer(); $response = $newmail->send_email($to, $message, $subject, $attach_file, $bcc_email); //$sql = "INSERT INTO `rtk_messages`(`id`, `sender`, `subject`, `message`, `receipient`, `state`) VALUES (NULL,'$sender','$subject','$message','$receipient','0')"; //$this->db->query($sql); //$object_id = $this->db->insert_id(); // $this->logData('23', $object_id); echo "Email Sent"; }
public function sendmail($output, $reportname, $email_address) { $this->load->helper('file'); include 'rtk_mailer.php'; $newmail = new rtk_mailer(); $this->load->library('mpdf'); $mpdf = new mPDF('', 'A4-L', 0, '', 15, 15, 16, 16, 9, 5, 'L'); $mpdf->WriteHTML($output); $emailAttachment = $mpdf->Output($reportname . '.pdf', 'S'); $attach_file = './pdf/' . $reportname . '.pdf'; if (!write_file('./pdf/' . $reportname . '.pdf', $mpdf->Output('report_name.pdf', 'S'))) { $this->session->set_flashdata('system_error_message', 'An error occured'); } else { $subject = '' . $reportname; $attach_file = './pdf/' . $reportname . '.pdf'; $bcc_email = '*****@*****.**'; $message = $output; $response = $newmail->send_email($email_address, $message, $subject, $attach_file, $bcc_email); // $response= $newmail->send_email(substr($email_address,0,-1),$message,$subject,$attach_file,$bcc_email); if ($response) { delete_files('./pdf/' . $reportname . '.pdf'); } } }