Мне нужно отправить электронные письма всем строкам таблицы базы данных с соответствующими данными.Я могу отправлять отдельные письма по их идентификатору, но теперь мне нужно отправить оптом.я сделал в чистом php, но в codeigniter не в состоянии выяснить.как это сделать.
мой контроллер
public function autoformcomplete()
{
$this->load->model('admin/Reminder_model');
$datan = $this->Reminder_model->autoformemail();
//this should be in whileloop, that i am not able to figure out
$email = $datan[0]['email'];
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'email-smtp.eu-west-1.amazonaws.com',
'smtp_port' => 587,
'smtp_crypto' => 'tls',
'smtp_user' => 'user',
'smtp_pass' => 'pass',
'mailtype' => 'text',
'charset' => 'utf-8',
);
$this->email->initialize($config);
$this->email->set_mailtype("html");
$this->email->set_newline("\r\n");
$this->email->set_crlf("\r\n");
$subject = "Complete Your Partially Filled Application-".$appid."";
$data['datan'] = $datan;
$mesg = $this->load->view('email/reminder/form_complete',$data,true);
$this->email->to($email);
$this->email->from('mail@mail.com','My Company');
$this->email->subject($subject);
$this->email->message($mesg);
$this->email->send();
echo "sent";
}
моя модель
public function autoformemail(){
$this->db->order_by('id', 'DESC');
$query = $this->db->get('appstbldata');
return $query->result_array();
}