From 3e6ba935edc352d80c97bd0e55ec540ab50bde77 Mon Sep 17 00:00:00 2001 From: Gabriel Passarelli Date: Tue, 17 Nov 2015 18:32:36 -0200 Subject: [PATCH] Always send html version and plain text --- src/MailGateway.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/MailGateway.php b/src/MailGateway.php index f350b8f..30ae1e7 100644 --- a/src/MailGateway.php +++ b/src/MailGateway.php @@ -204,21 +204,20 @@ protected function configureSender(&$emailProperties, &$email) protected function processEmailProperties($to, $message) { // If the notification is only a string, create it a email as the notification being the subject of the email - if(!is_array($message)){ - $original_message = $message; + $original_message = $message; + if(!is_array($original_message)){ $message = array( // Remove HTML tags and trim it to a max length of 75. 'subject' => substr(strip_tags($original_message),0,75).'...', + 'body' => $original_message, + ); + } + // Checks if the user passed only a string for the body of the email. + if(!is_array($message['body'])){ + $message['body'] = array( + 'html' => $message['body'], + 'plain' => Html2Text::convert($message['body']), ); - //Checks is the message is a HTML message, and generate the plain text version of it. - if($this->isHtml($original_message)) { - $message['body'] = array( - 'html' => $original_message, - 'plain' => Html2Text::convert($original_message), - ); - } else { - $message['body'] = $original_message; - } } // Merge and Overwrite configurations. @@ -260,6 +259,7 @@ protected function handleEmailBodyProperties($message) $this->isHtml($emailBodyProperties['body']) ){ $emailBodyProperties['contentType'] = 'text/html'; + } }