2011-12-03 85 views
0

我想在单个调用中使用sendmail将邮件发送给多个收件人。我正在使用cakephp 1.3。发送邮件到单个收件人工作正常。我想知道是否可以将邮件发送给多个收件人(通常是2-5个收件人)。使用sendgrid将邮件发送给多个收件人

$this->Email->smtpOptions = array('port'=>'587', 'timeout'=>'30', 'host' => 'smtp.sendgrid.net', 'username'=>'****', 'password'=>'****', 'client' => '***'); 
$this->Email->delivery = 'smtp'; 
$this->Email->from = 'Swiso Support <[email protected]>'; 
$this->Email->to = $user['email']; 
$this->Email->subject = $title; 
$this->Email->template = 'email'; 
$this->Email->sendAs = 'both'; 
$this->Email->send(); 

我可以将收件人数组传递给$this->Email->to

我很感激任何帮助。

+0

为什么不看在CakePHP的手册? –

+0

你在'to'字段中尝试过用逗号分隔的电子邮件吗? –

回答

0

答案很简单的一章: 号我一直在寻找这个太(使用Sendgrid),除非你想使用BCC领域,没有办法在同一个电话中进行。 你不应该担心只是在循环中发送它们。

0
foreach($recipients as $recipient) { 
    $this->Email->to .= $recipient['email'] . ","; 
} 

如果您不希望收件人能够看到您向谁发送邮件,发送密件抄送是更好的方法。在这种情况下,将

$this->Email->bcc 

,而不是

$this->Email->to 
相关问题