i have problem in code. want send 10 emails different clients. , put process in loop. , every loop update status column 1
. problem 1 email can send. loop doesn't proceed next email address. here's code:
$dummy = $this->users_model->get_dummy_email(); //produces 10 results. $valid_email = array(); $this->load->library('email'); $config = array( 'protocol' => 'sendmail', 'smtp_host' => 'mail.sample.ph', 'smtp_port' => 587, 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->email->initialize($config); $this->email->set_mailtype("html"); foreach($dummy $d) { //loop ok $this->email->clear(); $this->email->from('info@sample.ph', 'admin'); $this->email->to($d['email']); $this->email->cc('user@sample.ph, mymail@gmail.com'); $this->email->subject("test message using cron"); $this->email->message("test admin"); $send_mail = $this->email->send(); if($send_mail) { $this->users_model->updatedummystatus($d['id']); return true; } else { echo $this->email->print_debugger(); } }
can me what's error. tried put initialization inside loop , still same effect. 1 email can send.
you using return in loop after sending email. return statement ends execution of current function. remaining emails not send.
if($send_mail) { $this->users_model->updatedummystatus($d['id']); //return true; <--- remove line.. }
Comments
Post a Comment