如果满足条件,我目前正在尝试向多名员工发送电子邮件;用户列表按预期获得,但是当我尝试 foreach 数组时,我总是得到这个“你不能序列化或反序列化 PDO 实例”错误。
这是我目前必须做的功能
function mailUsers()
{
$date = '03-07'; //date('m-d');
$employee = $this->Employees->find()->where(['birthday LIKE' => '%' . $date . '%'])->toArray();
var_dump($employee);
foreach ($employee as $value) {
$email = new Email();
try {
$email->reset();
$email->from(['com@corp.co' => 'corp'])
->profile('SendGrid')
->to([$value['email'] => $value['full_name']])
->subject("test")
->emailFormat("both")
->template('default')
->send();
$this->Flash->success("Success.");
} catch (Exception $ex) {
echo 'Exception : ', $ex->getMessage(), "\n";
}
}
}
任何帮助都感激不尽!