Skip to content

Commit

Permalink
fix: set correct cc and bcc
Browse files Browse the repository at this point in the history
  • Loading branch information
motze92 committed Oct 26, 2020
1 parent 4ac68b6 commit 25c6db2
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion src/Transport/Office365MailTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ protected function getBody(Swift_Mime_SimpleMessage $message, $withAttachments =
]
],
'toRecipients' => $this->getTo($message),
'ccRecipients' => $this->getCc($message),
'bccRecipients' => $this->getBcc($message),
'subject' => $message->getSubject(),
'body' => [
'contentType' => $message->getBodyContentType() == "text/html" ? 'html' : 'text',
Expand Down Expand Up @@ -167,7 +169,51 @@ protected function getBody(Swift_Mime_SimpleMessage $message, $withAttachments =
*/
protected function getTo(Swift_Mime_SimpleMessage $message)
{
return collect($this->allContacts($message))->map(function ($display, $address) {
return collect((array) $message->getTo())->map(function ($display, $address) {
return $display ? [
'emailAddress' => [
'address' => $address,
'name' => $display
]
] : [
'emailAddress' => [
'address' => $address
]
];
})->values()->toArray();
}

/**
* Get the "Cc" payload field for the API request.
*
* @param \Swift_Mime_SimpleMessage $message
* @return string
*/
protected function getCc(Swift_Mime_SimpleMessage $message)
{
return collect((array) $message->getCc())->map(function ($display, $address) {
return $display ? [
'emailAddress' => [
'address' => $address,
'name' => $display
]
] : [
'emailAddress' => [
'address' => $address
]
];
})->values()->toArray();
}

/**
* Get the "Bcc" payload field for the API request.
*
* @param \Swift_Mime_SimpleMessage $message
* @return string
*/
protected function getBcc(Swift_Mime_SimpleMessage $message)
{
return collect((array) $message->getBcc())->map(function ($display, $address) {
return $display ? [
'emailAddress' => [
'address' => $address,
Expand Down

0 comments on commit 25c6db2

Please sign in to comment.