我想向不同的用户发送电子邮件,例如我使用的电子邮件 问题是需要很长时间
foreach($users as $user){
$this->Email->smtpOptions = array(
'port' => '25',
'timeout' => '30',
'host' => 'smtp.topnet.tn',
);
Envoie Mail
$this->Email->delivery = 'smtp';
$this->Email->reset();
$this->Email->from = $from;
$this->Email->to = $To;
$this->Email->subject = $subject;
$this->set('id_user',$user_id);
$this->set('password',$pass);
$this->Email->template = 'activcompte';
$this->Email->sendAs = 'both';
$this->Email->send();
}
答案 0 :(得分:1)
而不是使用foreach循环将邮件逐个发送给所有用户,只需创建一个包含所有用户的数组......就像...
$Recepients[0] => abc@gmail.com
$Recepients[1] => def@gmail.com
$Recepients[2] => ghi@gmail.com
....
and then assign this "$Recepients" array
$ this-> Email-> to = $ Recepients;