From ab8b46da49e1b2da2710b5c69c7b411d30138ead Mon Sep 17 00:00:00 2001 From: yehudah Date: Mon, 23 Apr 2018 21:12:54 +0000 Subject: * Fix lockfile erros * Contact form 7 integration * PHP 5.6 requirement git-svn-id: https://plugins.svn.wordpress.org/post-smtp/trunk@1863201 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- Postman/Postman-Mail/PostmanMailgunMailEngine.php | 6 ++-- Postman/Postman-Mail/PostmanSendGridMailEngine.php | 8 ++++-- Postman/Postman.php | 7 ++++- Postman/PostmanUtils.php | 3 ++ Postman/PostmanViewController.php | 4 +-- postman-smtp.php | 33 +++++++++++++++++++--- readme.txt | 13 ++++++--- style/testEmail.html | 2 +- 8 files changed, 58 insertions(+), 18 deletions(-) diff --git a/Postman/Postman-Mail/PostmanMailgunMailEngine.php b/Postman/Postman-Mail/PostmanMailgunMailEngine.php index 58def41..8258022 100644 --- a/Postman/Postman-Mail/PostmanMailgunMailEngine.php +++ b/Postman/Postman-Mail/PostmanMailgunMailEngine.php @@ -20,7 +20,7 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) { private $apiKey; private $domainName; - private $mandrillMessage; + private $mailgunMessage; /** * @@ -153,7 +153,7 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) { $result = array(); try { if ( $this->logger->isDebug() ) { - $this->logger->debug( 'Creating Mandrill service with apiKey=' . $this->apiKey ); + $this->logger->debug( 'Creating Mailgun service with apiKey=' . $this->apiKey ); } // send the message @@ -184,7 +184,7 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) { private function processSend( $mg ) { - if ( count( $this->mailgunMessage['to'] ) == 1 ) { + if ( count( $this->mailgunMessage['to'] ) <= 1 ) { return $mg->messages()->send( $this->domainName, array_filter( $this->mailgunMessage ) ); } else { diff --git a/Postman/Postman-Mail/PostmanSendGridMailEngine.php b/Postman/Postman-Mail/PostmanSendGridMailEngine.php index 28e3c83..eaa5b69 100644 --- a/Postman/Postman-Mail/PostmanSendGridMailEngine.php +++ b/Postman/Postman-Mail/PostmanSendGridMailEngine.php @@ -188,14 +188,16 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { $response_body = json_decode( $response->body() ); - if ( isset( $response_body->errors[0]->message ) ) { - $this->transcript = $response_body->errors[0]->message; + if ( isset( $response_body->errors[0]->message ) || $response->statusCode() != 200 ) { + + $e = $response->statusCode() != 200 ? sprintf( __( 'ERROR: Status code is %1$s', Postman::TEXT_DOMAIN ), $response->statusCode() ) : $response_body->errors[0]->message; + $this->transcript = $e; $this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS; $this->transcript .= print_r( $mail, true ); $this->logger->debug( 'Transcript=' . $this->transcript ); - throw new Exception( $response_body->errors[0]->message ); + throw new Exception( $e ); } $this->transcript = print_r( $response->body(), true ); $this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS; diff --git a/Postman/Postman.php b/Postman/Postman.php index 7df883a..ba639e3 100644 --- a/Postman/Postman.php +++ b/Postman/Postman.php @@ -54,6 +54,7 @@ class Postman { require_once 'PostmanConfigTextHelper.php'; require_once 'Postman-Email-Log/PostmanEmailLogPostType.php'; require_once 'Postman-Mail/PostmanMyMailConnector.php'; + require_once 'Postman-Mail/PostmanContactForm7.php'; //require_once 'Postman-Mail/PostmanWooCommerce.php'; // get plugin metadata - alternative to get_plugin_data @@ -106,6 +107,9 @@ class Postman { // MyMail integration new PostmanMyMailConnector( $rootPluginFilenameAndPath ); + // Contact form 7 + new Postsmtp_ContactForm7; + // WooCommerce Integration //new PostmanWoocommerce(); @@ -153,6 +157,7 @@ class Postman { $this, 'on_deactivation', ) ); + } public function post_smtp_wpml_admin_notice() { @@ -426,7 +431,7 @@ class Postman { // because __FILE__ returns the wrong path if the plugin is installed as a symlink $shortLocale = substr( get_locale(), 0, 2 ); if ( $shortLocale != 'en' ) { - $langDir = 'postman-smtp/Postman/languages'; + $langDir = 'post-smtp/Postman/languages'; $success = load_plugin_textdomain( Postman::TEXT_DOMAIN, false, $langDir ); if ( $this->logger->isDebug() ) { if ( $success ) { diff --git a/Postman/PostmanUtils.php b/Postman/PostmanUtils.php index b70b2b8..7eaebe5 100644 --- a/Postman/PostmanUtils.php +++ b/Postman/PostmanUtils.php @@ -243,6 +243,9 @@ class PostmanUtils { return $success; } static function createLockFile( $tempDirectory = null ) { + if ( self::lockFileExists() ) { + self::deleteLockFile(); + } $path = PostmanUtils::calculateTemporaryLockPath( $tempDirectory ); $success = @fopen( $path, 'xb' ); if ( PostmanUtils::$logger->isTrace() ) { diff --git a/Postman/PostmanViewController.php b/Postman/PostmanViewController.php index 49388f3..5fb8cb1 100644 --- a/Postman/PostmanViewController.php +++ b/Postman/PostmanViewController.php @@ -57,7 +57,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) { die(); } - echo PostmanUtils::deleteLockFile() == true ? __('Success', Postman::TEXT_DOMAIN ) : __('Failed, try again.', Postman::TEXT_DOMAIN ); + echo PostmanUtils::deleteLockFile() == true ? __('Success, try to send test email.', Postman::TEXT_DOMAIN ) : __('Failed, try again.', Postman::TEXT_DOMAIN ); die(); } @@ -307,7 +307,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) { echo '

- Version ' . $version . ' released with Gmail upgrade and notifications: Read Here + Version ' . $version . ' released with lockfile fix and new PHP requirement: Read Here