diff options
author | Vincent Song <vincent.wsong@gmail.com> | 2016-06-10 14:28:07 -0400 |
---|---|---|
committer | Vincent Song <vincent.wsong@gmail.com> | 2016-06-10 14:28:07 -0400 |
commit | 6b3d22c743dd8c78b0af78693834908ba7d46eae (patch) | |
tree | 0c5ed480018e70f0303bc35e2758f252caa01ded | |
parent | 2691ddd138dcbfc7eaca768ed92f911c8afd8b82 (diff) | |
download | php-sparkpost-6b3d22c743dd8c78b0af78693834908ba7d46eae.zip php-sparkpost-6b3d22c743dd8c78b0af78693834908ba7d46eae.tar.gz php-sparkpost-6b3d22c743dd8c78b0af78693834908ba7d46eae.tar.bz2 |
It won't break anymore if there's no CC or BCC
-rw-r--r-- | lib/SparkPost/Transmission.php | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/lib/SparkPost/Transmission.php b/lib/SparkPost/Transmission.php index a356c9b..7d45928 100644 --- a/lib/SparkPost/Transmission.php +++ b/lib/SparkPost/Transmission.php @@ -33,12 +33,14 @@ class Transmission extends Resource } //loop through all BCC recipients - foreach ($bccList as $bccRecipient) { - $newRecipient = [ - 'address' => $bccRecipient['address'], - 'header_to' => $originalRecipient, - ]; - array_push($recipientsList, $newRecipient); + if(isset($bccList)){ + foreach ($bccList as $bccRecipient) { + $newRecipient = [ + 'address' => $bccRecipient['address'], + 'header_to' => $originalRecipient, + ]; + array_push($recipientsList, $newRecipient); + } } //Delete the BCC object/array @@ -62,24 +64,27 @@ class Transmission extends Resource $originalRecipient = '<' . $modifiedPayload['recipients'][0]['address'] . '>'; } + + if(isset($ccList)){ + foreach ($ccList as $ccRecipient) { + $newRecipient = [ + 'address' => $ccRecipient['address'], + 'header_to' => $originalRecipient, + ]; - foreach ($ccList as $ccRecipient) { - $newRecipient = [ - 'address' => $ccRecipient['address'], - 'header_to' => $originalRecipient, - ]; - - //if name exists, then use "Name" <Email> format. Otherwise, just email will suffice. - if(isset($ccRecipient['name'])) { - $ccCustomHeadersList = $ccCustomHeadersList . ' "' . $ccRecipient['name'] - . '" <' . $ccRecipient['address'] . '>,'; - } else { - $ccCustomHeadersList = $ccCustomHeadersList . ' ' . $ccRecipient['address']; - } - - array_push($recipientsList, $newRecipient); + //if name exists, then use "Name" <Email> format. Otherwise, just email will suffice. + if(isset($ccRecipient['name'])) { + $ccCustomHeadersList = $ccCustomHeadersList . ' "' . $ccRecipient['name'] + . '" <' . $ccRecipient['address'] . '>,'; + } else { + $ccCustomHeadersList = $ccCustomHeadersList . ' ' . $ccRecipient['address']; + } + + array_push($recipientsList, $newRecipient); + } } + //Creates customHeaders and adds CSV list of CC emails $customHeaders = array("CC" => $ccCustomHeadersList); $modifiedPayload['customHeaders'] = $customHeaders; |