From 48439c162facd2b497b0c88e5c96a1986534dae3 Mon Sep 17 00:00:00 2001 From: Davide Bellini Date: Mon, 30 May 2016 18:15:40 +0200 Subject: [PATCH] Revert Sparkpost changes, back to "email_rfc822" --- .../Mail/Transport/SparkPostTransport.php | 44 +------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/src/Illuminate/Mail/Transport/SparkPostTransport.php b/src/Illuminate/Mail/Transport/SparkPostTransport.php index e4479d0baa29..d5651cb2590d 100644 --- a/src/Illuminate/Mail/Transport/SparkPostTransport.php +++ b/src/Illuminate/Mail/Transport/SparkPostTransport.php @@ -2,7 +2,6 @@ namespace Illuminate\Mail\Transport; -use Swift_Encoding; use Swift_Mime_Message; use GuzzleHttp\ClientInterface; @@ -53,24 +52,11 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) 'json' => [ 'recipients' => $recipients, 'content' => [ - 'html' => $message->getBody(), - 'from' => $this->getFrom($message), - 'reply_to' => $this->getReplyTo($message), - 'subject' => $message->getSubject(), + 'email_rfc822' => $message->toString(), ], ], ]; - if ($attachments = $message->getChildren()) { - $options['json']['content']['attachments'] = array_map(function ($attachment) { - return [ - 'type' => $attachment->getContentType(), - 'name' => $attachment->getFileName(), - 'data' => Swift_Encoding::getBase64Encoding()->encodeString($attachment->getBody()), - ]; - }, $attachments); - } - return $this->client->post('https://api.sparkpost.com/api/v1/transmissions', $options); } @@ -99,38 +85,12 @@ protected function getRecipients(Swift_Mime_Message $message) } $recipients = array_map(function ($address) { - return ['address' => ['email' => $address, 'header_to' => $address]]; + return compact('address'); }, $to); return $recipients; } - /** - * Get the "from" contacts in the format required by SparkPost. - * - * @param Swift_Mime_Message $message - * @return array - */ - protected function getFrom(Swift_Mime_Message $message) - { - return array_map(function ($email, $name) { - return compact('name', 'email'); - }, array_keys($message->getFrom()), $message->getFrom())[0]; - } - - /** - * Get the 'reply_to' headers and format as required by SparkPost. - * - * @param Swift_Mime_Message $message - * @return string - */ - protected function getReplyTo(Swift_Mime_Message $message) - { - if (is_array($message->getReplyTo())) { - return current($message->getReplyTo()).' <'.key($message->getReplyTo()).'>'; - } - } - /** * Get the API key being used by the transport. *