1
我正在使用cakePHP向sendgrid发送smtp电子邮件。我希望能够对多个收件人执行一次send(),并允许sendgrid使用变量将数组中的名称替换为-name-。使用sendgrid在cakephp中批量发送电子邮件
在我的CakePHP控制器的方法我测试:
保护功能fwtEmail(){
$config = 'sendGrid';
$subject = "test";
$Email = new CakeEmail('sendGrid');
$names = array('[email protected]'=>'John','[email protected]' =>'Paul');
$Email->To($names);
$vars = array('Paul', 'John');
$Email->viewVars(array('name' => $vars));
$Email->from(array('[email protected]' => 'Jim'));
$Email->subject($subject);
$template = 'bulk';
$Email->template($template, 'default');
$Email->sendAs = 'both';
return $Email->send();
}