$to ); foreach(array_keys($headers) as $header) { if(strtoupper($header) == 'BCC') { $to['BCC'] = $headers[$header]; } elseif(strtoupper($header) == 'CC') { $to['CC'] = $headers[$header]; } } $ret = $mail_obj -> send($to,$headers,$msg); if ($ret instanceof PEAR_Error) { logging('ERROR',"Error sending email to $to : ".$ret -> getMessage()); return -1; } return true; }