diff --git a/Postman/Postman-Mail/PostmanSendinblueMailEngine.php b/Postman/Postman-Mail/PostmanSendinblueMailEngine.php index e8bf311e..aebaf7f3 100644 --- a/Postman/Postman-Mail/PostmanSendinblueMailEngine.php +++ b/Postman/Postman-Mail/PostmanSendinblueMailEngine.php @@ -90,10 +90,10 @@ public function send( PostmanMessage $message ) { $sender = $message->getFromAddress(); $senderEmail = !empty( $sender->getEmail() ) ? $sender->getEmail() : $options->getMessageSenderEmail(); - $senderName = !empty( $sender->getName() ) ? $sender->getName() : $options->getMessageSenderName(); + $senderName = !empty( $sender->getName() ) ? $sender->getName() : $options->getMessageSenderName(); $headers = array(); - $sender->log( $this->logger, 'From' ); + $sender->log( $this->logger, 'From' ); $sendSmtpEmail['sender'] = array( 'name' => $senderName, @@ -109,9 +109,13 @@ public function send( PostmanMessage $message ) { if ( !array_key_exists( $recipient->getEmail(), $duplicates ) ) { $tos[] = array( - 'email' => $recipient->getEmail(), - 'name' => '$recipient->getName()' + 'email' => $recipient->getEmail() ); + + if( !empty( $recipient->getName() ) ) { + $tos['name'] = $recipient->getName(); + } + $duplicates[] = $recipient->getEmail(); } @@ -138,9 +142,12 @@ public function send( PostmanMessage $message ) { // $replyTo is null or a PostmanEmailAddress object if ( isset( $replyTo ) ) { $sendSmtpEmail['replyTo'] = array( - 'email' => $replyTo->getEmail(), - 'name' => '$replyTo->getName()' + 'email' => $replyTo->getEmail() ); + + if( !empty( $replyTo->getName() ) ) { + $sendSmtpEmail['name'] = $replyTo->getName(); + } } // add the Postman signature - append it to whatever the user may have set @@ -176,16 +183,20 @@ public function send( PostmanMessage $message ) { $recipient->log($this->logger, 'Cc'); $cc[] = array( - 'name' => '$recipient->getName()', 'email' => $recipient->getEmail() ); + + if( !empty( $recipient->getName() ) ) { + $cc['name'] = $recipient->getName(); + } + $duplicates[] = $recipient->getEmail(); } } if( !empty( $cc ) ) - $sendSmtpEmail['cc'] = $cc; + $sendSmtpEmail['cc'] = $cc; $bcc = array(); $duplicates = array(); @@ -205,7 +216,7 @@ public function send( PostmanMessage $message ) { } if( !empty( $bcc ) ) - $sendSmtpEmail['bcc'] = $bcc; + $sendSmtpEmail['bcc'] = $bcc; // add attachments $this->logger->debug( 'Adding attachments' ); @@ -237,12 +248,12 @@ public function send( PostmanMessage $message ) { } $response = $apiInstance->sendTransacEmail($sendSmtpEmail); - - $this->transcript = print_r( $response, true ); - $this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS; - $this->transcript .= print_r( $sendSmtpEmail, true ); - $this->logger->debug( 'Transcript=' . $this->transcript ); - + + $this->transcript = print_r( $response, true ); + $this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS; + $this->transcript .= print_r( $sendSmtpEmail, true ); + $this->logger->debug( 'Transcript=' . $this->transcript ); + } catch (Exception $e) { $this->transcript = $e->getMessage();