private function addListToRecipients($payload, $listName)
{
$originalAddress = $this->toAddressString($payload['recipients'][0]['address']);
foreach ($payload[$listName] as $recipient) {
$recipient['address'] = $this->toAddressObject($recipient['address']);
$recipient['address']['header_to'] = $originalAddress;
// remove name from address - name is only put in the header for cc and not at all for bcc
if (isset($recipient['address']['name'])) {
unset($recipient['address']['name']);
}
array_push($payload['recipients'], $recipient);
}
//Delete the original object from the payload.
unset($payload[$listName]);
return $payload;
}