Skip to content

Commit

Permalink
revert broken change to mailgun
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 4, 2016
1 parent 99d2107 commit ebdc5d7
Showing 1 changed file with 11 additions and 40 deletions.
51 changes: 11 additions & 40 deletions src/Illuminate/Mail/Transport/MailgunTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)

$options = ['auth' => ['api', $this->key]];

$to = $this->getTo($message);

$message->setBcc([]);

if (version_compare(ClientInterface::VERSION, '6') === 1) {
$options['multipart'] = [
['name' => 'to', 'contents' => $this->getTo($message)],
['name' => 'cc', 'contents' => $this->getCc($message)],
['name' => 'bcc', 'contents' => $this->getBcc($message)],
['name' => 'to', 'contents' => $to],
['name' => 'message', 'contents' => $message->toString(), 'filename' => 'message.mime'],
];
} else {
$options['body'] = [
'to' => $this->getTo($message),
'cc' => $this->getCc($message),
'bcc' => $this->getBcc($message),
'to' => $to,
'message' => new PostFile('message', $message->toString()),
];
}
Expand All @@ -83,45 +83,16 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
* Get the "to" payload field for the API request.
*
* @param \Swift_Mime_Message $message
* @return string
* @return array
*/
protected function getTo(Swift_Mime_Message $message)
{
return $this->formatAddress($message->getTo());
}

/**
* Get the "cc" payload field for the API request.
*
* @param \Swift_Mime_Message $message
* @return string
*/
protected function getCc(Swift_Mime_Message $message)
{
return $this->formatAddress($message->getCc());
}

/**
* Get the "bcc" payload field for the API request.
*
* @param \Swift_Mime_Message $message
* @return string
*/
protected function getBcc(Swift_Mime_Message $message)
{
return $this->formatAddress($message->getBcc());
}

/**
* Get Comma-Separated Address (with name, if available) for the API request.
*
* @param array $contacts
* @return string
*/
protected function formatAddress($contacts)
{
$formatted = [];

$contacts = array_merge(
(array) $message->getTo(), (array) $message->getCc(), (array) $message->getBcc()
);

foreach ($contacts as $address => $display) {
$formatted[] = $display ? $display." <$address>" : $address;
}
Expand Down

0 comments on commit ebdc5d7

Please sign in to comment.