CodeExplorer formatAddresses example
foreach ($addresses as $address) { $formattedAddresses[] =
$this->
formatAddress($address);
} return $formattedAddresses;
} private function getPayload(Email
$email, Envelope
$envelope): array
{ $payload =
[ 'sender' =>
$this->
formatAddress($envelope->
getSender()),
'to' =>
$this->
formatAddresses($this->
getRecipients($email,
$envelope)),
'subject' =>
$email->
getSubject(),
];
if ($attachements =
$this->
prepareAttachments($email)) { $payload['attachment'
] =
$attachements;
} if ($emails =
$email->
getReplyTo()) { $payload['replyTo'
] =
current($this->
formatAddresses($emails));
} if ($emails =
$email->
getCc()) { $payload['cc'
] =
$this->
formatAddresses($emails);
} $sentMessage->
setMessageId($result['emails'
][0
]['message_id'
]);
return $response;
} private function getPayload(Email
$email, Envelope
$envelope): array
{ $payload =
[ 'from' =>
$this->
formatAddress($envelope->
getSender()),
'to' =>
$this->
formatAddresses($this->
getRecipients($email,
$envelope)),
'subject' =>
$email->
getSubject(),
'project_id' =>
$this->projectId,
];
if ($emails =
$email->
getCc()) { $payload['cc'
] =
$this->
formatAddresses($emails);
} if ($emails =
$email->
getBcc()) { $payload['bcc'
] =
$this->
formatAddresses($emails);
} if ($email->
getTextBody()) { $payload['text'
] =
$email->
getTextBody();
}