From efd7b4d8d0d58f92e8080ffe2da669bb451b622b Mon Sep 17 00:00:00 2001 From: yehudah Date: Mon, 20 May 2019 05:21:18 +0000 Subject: = 2.0.2 - 2019-05-19 * Fixed: Sendgrid code fix. * Fixed: Default method (nothing configured) will use the default mail on the server and not SMTP. --- Postman/Postman-Mail/PostmanContactForm7.php | 2 +- Postman/Postman-Mail/PostmanModuleTransport.php | 5 +++++ Postman/Postman-Mail/PostmanSendGridMailEngine.php | 4 ++-- Postman/Postman-Mail/PostmanZendMailEngine.php | 4 +++- Postman/Postman-Mail/Zend-1.12.10/Mail.php | 7 +++---- Postman/PostmanViewController.php | 2 +- postman-smtp.php | 4 ++-- readme.txt | 24 +++++++++++++--------- 8 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Postman/Postman-Mail/PostmanContactForm7.php b/Postman/Postman-Mail/PostmanContactForm7.php index 64f4f5f..40fd698 100644 --- a/Postman/Postman-Mail/PostmanContactForm7.php +++ b/Postman/Postman-Mail/PostmanContactForm7.php @@ -13,7 +13,7 @@ class Postsmtp_ContactForm7 { } public function change_rest_response( $response ) { - if ( $response['status'] == 'mail_failed' ) { + if ( array_key_exists('status', $response) && $response['status'] == 'mail_failed' ) { $message = $this->result_error ['exception']->getMessage(); if ( ! $message || $message == '' ) { diff --git a/Postman/Postman-Mail/PostmanModuleTransport.php b/Postman/Postman-Mail/PostmanModuleTransport.php index 1dcc8b0..37d692d 100644 --- a/Postman/Postman-Mail/PostmanModuleTransport.php +++ b/Postman/Postman-Mail/PostmanModuleTransport.php @@ -503,6 +503,11 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT $deliveryDetails ['transport_name'] = $this->getTransportDescription ( $this->getSecurityType () ); $deliveryDetails ['host'] = $this->getHostname () . ':' . $this->getPort (); $deliveryDetails ['auth_desc'] = $this->getAuthenticationDescription ( $this->getAuthenticationType () ); + + if ( $deliveryDetails ['host'] == 'localhost:25' ) { + $deliveryDetails ['transport_name'] = __( 'Sendmail (server defualt - not SMTP)', 'post-smtp'); + } + /* translators: where (1) is the transport type, (2) is the host, and (3) is the Authentication Type (e.g. Postman will send mail via smtp.gmail.com:465 using OAuth 2.0 authentication.) */ return sprintf ( __ ( 'Postman will send mail via %1$s to %2$s using %3$s authentication.', 'post-smtp' ), '' . $deliveryDetails ['transport_name'] . '', '' . $deliveryDetails ['host'] . '', '' . $deliveryDetails ['auth_desc'] . '' ); } diff --git a/Postman/Postman-Mail/PostmanSendGridMailEngine.php b/Postman/Postman-Mail/PostmanSendGridMailEngine.php index b3e13b9..311d7cc 100644 --- a/Postman/Postman-Mail/PostmanSendGridMailEngine.php +++ b/Postman/Postman-Mail/PostmanSendGridMailEngine.php @@ -117,7 +117,7 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { $bccEmails = array(); foreach ( ( array ) $message->getBccRecipients() as $recipient ) { $recipient->log($this->logger, 'Bcc'); - $bccEmails[] = new \SendGrid\Mail\Cc( $recipient->getEmail(), $recipient->getName() ); + $bccEmails[] = new \SendGrid\Mail\Bcc( $recipient->getEmail(), $recipient->getName() ); } $email->addBccs($bccEmails); @@ -166,7 +166,7 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { if ( isset( $response_body->errors[0]->message ) || ! $email_sent ) { - $e = ! $email_sent ? $this->errorCodesMap($response_code) : $response_body->errors[0]->message; + $e = ! isset( $response_body->errors[0]->message ) ? $this->errorCodesMap($response_code) : $response_body->errors[0]->message; $this->transcript = $e; $this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS; $this->transcript .= print_r( $email, true ); diff --git a/Postman/Postman-Mail/PostmanZendMailEngine.php b/Postman/Postman-Mail/PostmanZendMailEngine.php index e4ea286..86905f8 100644 --- a/Postman/Postman-Mail/PostmanZendMailEngine.php +++ b/Postman/Postman-Mail/PostmanZendMailEngine.php @@ -171,10 +171,12 @@ if ( ! class_exists( 'PostmanZendMailEngine' ) ) { $this->logger->debug( 'Create the Zend_Mail transport' ); $zendTransport = $this->transport->createZendMailTransport( $this->transport->getHostname(), array() ); + $transport = $this->transport instanceof PostmanDefaultModuleTransport ? null : $zendTransport; + try { // send the message $this->logger->debug( 'Sending mail' ); - $mail->send( $zendTransport ); + $mail->send( $transport ); if ( $this->logger->isInfo() ) { $this->logger->info( sprintf( 'Message %d accepted for delivery', PostmanState::getInstance()->getSuccessfulDeliveries() + 1 ) ); } diff --git a/Postman/Postman-Mail/Zend-1.12.10/Mail.php b/Postman/Postman-Mail/Zend-1.12.10/Mail.php index d597ea7..67ba4b9 100644 --- a/Postman/Postman-Mail/Zend-1.12.10/Mail.php +++ b/Postman/Postman-Mail/Zend-1.12.10/Mail.php @@ -1175,10 +1175,9 @@ class Postman_Zend_Mail extends Postman_Zend_Mime_Message { if ($transport === null) { if (! self::$_defaultTransport instanceof Postman_Zend_Mail_Transport_Abstract) { - require_once 'Zend/Mail/Transport/Sendmail.php'; - - $replyTo = self::getDefaultReplyTo(); - $transport = new Postman_Zend_Mail_Transport_Sendmail("-f{$replyTo['email']}"); + require_once 'Mail/Transport/Sendmail.php'; + + $transport = new Postman_Zend_Mail_Transport_Sendmail("-f{$this->_from}"); } else { $transport = self::$_defaultTransport; } diff --git a/Postman/PostmanViewController.php b/Postman/PostmanViewController.php index 8dffa31..55a56e9 100644 --- a/Postman/PostmanViewController.php +++ b/Postman/PostmanViewController.php @@ -320,7 +320,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) { echo '

- Version ' . $version . ' Mailer Type: Read Here + Version ' . $version . ' Sendgrid code fix and default delivery changes: Read Here