1
我的代碼有問題。我想發送來自不同客戶的10封電子郵件。我把過程放在一個循環中。每一個循環我都將狀態列更新爲1
。我的問題是隻能發送1封電子郵件。我的循環不會繼續到下一個電子郵件地址。這是我的代碼:如何在CodeIgniter中使用循環發送多個電子郵件?
$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 as $d) { //loop is ok
$this->email->clear();
$this->email->from('[email protected]', 'Admin');
$this->email->to($d['email']);
$this->email->cc('[email protected], [email protected]');
$this->email->subject("TEST MESSAGE ONLY USING CRON");
$this->email->message("TEST FROM ADMIN");
$send_mail = $this->email->send();
if($send_mail) {
$this->Users_model->updateDummyStatus($d['id']);
return true;
} else {
echo $this->email->print_debugger();
}
}
你能幫我什麼是我的錯誤。我試過也把這個初始化放在循環中,但效果仍然一樣。只能發送1封電子郵件。
感謝您的幫助。有用。 :) – Jerielle