0

我想向不同的用户发送电子邮件,例如我使用的电子邮件问题是需要很长时间

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();
}
4

1 回答 1

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;

于 2013-03-02T11:22:21.783 回答