cakephp send mail bcc
snippet in php

cakephp send mail bcc

user5057

// $to_emails = array(
//	'abc1@gmail.com',
//	'abc2@gmail.com',
//	'abc3@gmail.com',
//);

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(),
     );
   }
 }