cakephp send mail bcc

Solutions on MaxInterview for cakephp send mail bcc by the best coders in the world

showing results for - "cakephp send mail bcc"
Salvatore
29 Jan 2020
1// $to_emails = array(
2//	'abc1@gmail.com',
3//	'abc2@gmail.com',
4//	'abc3@gmail.com',
5//);
6
7public function send($to_emails, $subject, $template, $data){
8   try{
9     $email = new CakeEmail('gmail');
10
11     $email->template($template)
12
13       ->bcc($to_emails)
14       //->to($to_emails)		
15       // ->cc($to_emails)
16       ->viewVars($data)
17       ->subject($subject);
18
19     $email->send();
20
21     return array(
22       'status' => true
23     );
24   } catch(SocketException $e) {
25     CakeLog::write($this->log_module, 
26                    "Send email to \"" . (is_array($to_emails) ? implode(', ', $to_emails) : $to_emails) . "\" with template \"" . 
27                    $template . "\" Failed because " . $e->getMessage());
28     return array(
29       'status' => false,
30       'message' => "Send email to \"" . (is_array($to_emails) ? implode(', ', $to_emails) : $to_emails) . "\" with template \"" . 
31       $template . "\" Failed because "  . $e->getMessage(),
32       'error_message' => $e->getMessage(),
33     );
34   }
35 }