diff --git a/classes/postal.php b/classes/postal.php index 3a62ecb..3eaabf2 100644 --- a/classes/postal.php +++ b/classes/postal.php @@ -12,6 +12,39 @@ public static function send($subject, $body, $to, $to_name = '', $from = null, $ // Create a new message $message = new \Postal\SendMessage($client); + if (is_array($bcc)) + if (\Fuel::$env == \Fuel::PRODUCTION) { + $bccs = array(); + foreach($bcc as $bcc_email=>$bcc_name) { + if(is_array($bcc_name)) { + foreach($bcc_name as $bcc_subemail=>$bcc_subname) { + if (preg_match('/(.+?)(?:\+.+?)*@(.+?\..+)/', $bcc_subemail, $matches)) { + $bcc_subemail = $matches[1] . '@' . $matches[2]; + if(isset($bccs[$bcc_subemail])) { + continue; + } + $bccs[$bcc_subemail] = $bcc_subname; + } + } + } else { + if(isset($bccs[$bcc_subemail])) { + continue; + } + $bccs[$bcc_subemail] = $bcc_subname; + } + } + foreach($bccs as $email=>$name) { + $message->bcc($name . ' <' . $email . '>'); + } + } else { + $env = getenv('EMAIL'); + if (!$env) { + $env = 'root@localhost'; + } + $message->bcc('Test User'.' <'.$env.'>'); + } + } + if (is_array($to)) { $uniq = []; foreach ($to as $ar_to_email => $ar_to_name):