Skip to content

Commit

Permalink
Add BCC method
Browse files Browse the repository at this point in the history
  • Loading branch information
forestlovewood authored Jun 14, 2017
1 parent 9f1c852 commit 011b275
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions classes/postal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 011b275

Please sign in to comment.