Email class - CodeIgniter PHP - Send email to multiple members -
i have been trying send email multiple members within database. managed application send 1 email specific users emails, when use list function errors (undefined index) supposedly in libraries/email.php file far aware should not have change email library file. working on localhost , here code:
function send(){ $this->load->model('mail_model', 'emails'); $emails=$this->emails->get_emails(); foreach($emails $row){ if($row['email']){ $this->email->set_newline("\r\n"); $this->email->from('myemail@test.com', 'my name'); $this->email->to($row['email']); $this->email->subject('test multiple receivers'); $this->email->message('test'); $this->email->send(); echo $this->email->print_debugger(); $this->email->clear(); $path = $this->config->item('server_root'); } if($this->email->send()) { //echo 'your email sent.'; $data['main_content'] = 'signup_confirmation'; $this->load->view('includes/template', $data); } else { show_error($this->email->print_debugger()); } } }
i have autoloaded email library in config files. code model:
class mail_model extends ci_model { function get($id = null) { $this->db->select('mailing_member_id', 'mailing_list_id', 'email_address'); $this->db->from('mailing_members'); if (!is_null($id)) $this->db->where('mailing_member_id', $id); $this->db->order_by('mailing_member_id', 'desc'); return $this->db->get()->result(); }
your model's get()
method returns object instead of array. try:
return $this->db->get()->result_array();
also, need $row['email_address']
not $row['email']
if
statement.
Comments
Post a Comment