Answers for "cakephp send mail bcc"

PHP
2

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(),
     );
   }
 }
Posted by: Guest on November-24-2020

Browse Popular Code Answers by Language