diff --git a/src/Illuminate/Mail/Transport/SparkPostTransport.php b/src/Illuminate/Mail/Transport/SparkPostTransport.php index 98612f9885b5..9fec38354418 100644 --- a/src/Illuminate/Mail/Transport/SparkPostTransport.php +++ b/src/Illuminate/Mail/Transport/SparkPostTransport.php @@ -54,6 +54,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) 'content' => [ 'html' => $message->getBody(), 'from' => $this->getFrom($message), + 'reply_to' => $this->getReplyTo($message), 'subject' => $message->getSubject(), ], ], @@ -106,6 +107,19 @@ protected function getFrom(Swift_Mime_Message $message) }, 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. *