cakephp send mail bcc code example
Example: cakephp send mail bcc
// $to_emails = array(
// '[email protected]',
// '[email protected]',
// '[email protected]',
//);
public function send($to_emails, $subject, $template, $data){
try{
$email = new CakeEmail('gmail');
$email->template($template)
->bcc($to_emails)
//->to($to_emails)
// ->cc($to_emails)
->viewVars($data)
->subject($subject);
$email->send();
return array(
'status' => true
);
} catch(SocketException $e) {
CakeLog::write($this->log_module,
"Send email to \"" . (is_array($to_emails) ? implode(', ', $to_emails) : $to_emails) . "\" with template \"" .
$template . "\" Failed because " . $e->getMessage());
return array(
'status' => false,
'message' => "Send email to \"" . (is_array($to_emails) ? implode(', ', $to_emails) : $to_emails) . "\" with template \"" .
$template . "\" Failed because " . $e->getMessage(),
'error_message' => $e->getMessage(),
);
}
}