I'm currently trying to send an email to multiple employees if a condition is met; the list of users is gotten as expected but when I try to foreach the array I always get this "You cannot serialize or unserialize PDO instances" error.
this is the function I currently have to do it
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";
}
}
}
Any help will be much appreciated!