summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Postman/Postman-Mail/PostmanMailgunMailEngine.php38
-rw-r--r--Postman/Postman-Mail/PostmanMailgunTransport.php2
-rw-r--r--Postman/Postman-Mail/PostmanTransportRegistry.php2
-rw-r--r--Postman/Postman.php33
-rw-r--r--Postman/PostmanInstaller.php4
-rw-r--r--Postman/PostmanViewController.php2
-rw-r--r--postman-smtp.php4
-rw-r--r--readme.txt7
8 files changed, 82 insertions, 10 deletions
diff --git a/Postman/Postman-Mail/PostmanMailgunMailEngine.php b/Postman/Postman-Mail/PostmanMailgunMailEngine.php
index 360201c..58def41 100644
--- a/Postman/Postman-Mail/PostmanMailgunMailEngine.php
+++ b/Postman/Postman-Mail/PostmanMailgunMailEngine.php
@@ -90,7 +90,7 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) {
$recipient->log( $this->logger, 'To' );
$recipients[] = $recipient->getEmail();
}
- $this->mailgunMessage['to'] = implode( ',', $recipients );
+ $this->mailgunMessage['to'] = $recipients;
// add the cc recipients
$recipients = array();
@@ -164,7 +164,7 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) {
$mg = Mailgun::create( $this->apiKey );
// Make the call to the client.
- $result = $mg->messages()->send( $this->domainName, array_filter( $this->mailgunMessage ) );
+ $result = $this->processSend( $mg );
if ( $this->logger->isInfo() ) {
$this->logger->info( sprintf( 'Message %d accepted for delivery', PostmanState::getInstance()->getSuccessfulDeliveries() + 1 ) );
@@ -181,6 +181,40 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) {
}
}
+
+ private function processSend( $mg ) {
+
+ if ( count( $this->mailgunMessage['to'] ) == 1 ) {
+
+ return $mg->messages()->send( $this->domainName, array_filter( $this->mailgunMessage ) );
+ } else {
+ $chunks = array_chunk( $this->mailgunMessage['to'], 1000, true );
+
+ $result = array();
+ foreach ( $chunks as $key => $emails ) {
+ $this->mailgunMessage['to'] = $emails;
+ $recipient_variables = $this->getRecipientVariables( $emails );
+ $this->mailgunMessage['recipient-variables'] = $recipient_variables;
+
+ $result[] = $mg->messages()->send( $this->domainName, array_filter( $this->mailgunMessage ) );
+
+ // Don't have a reason just wait a bit before sending the next chunk
+ sleep(2);
+ }
+
+ return $result;
+ }
+ }
+
+ private function getRecipientVariables( $emails ) {
+ $recipient_variables = array();
+ foreach ( $emails as $key => $email ) {
+ $recipient_variables[$email] = array( 'id' => $key );
+ }
+
+ return json_encode( $recipient_variables );
+ }
+
private function addHeader( $name, $value, $deprecated = '' ) {
if ( $value && ! empty( $value ) ) {
$this->mailgunMessage['h:' . $name] = $value;
diff --git a/Postman/Postman-Mail/PostmanMailgunTransport.php b/Postman/Postman-Mail/PostmanMailgunTransport.php
index c3565ea..9a5e9d2 100644
--- a/Postman/Postman-Mail/PostmanMailgunTransport.php
+++ b/Postman/Postman-Mail/PostmanMailgunTransport.php
@@ -154,7 +154,7 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
$overrideItem ['auth_items'] = array(
array(
'selected' => true,
- 'name' => __( 'API Kkey', Postman::TEXT_DOMAIN ),
+ 'name' => __( 'API Key', Postman::TEXT_DOMAIN ),
'value' => 'api_key',
),
);
diff --git a/Postman/Postman-Mail/PostmanTransportRegistry.php b/Postman/Postman-Mail/PostmanTransportRegistry.php
index ceaef7c..77654eb 100644
--- a/Postman/Postman-Mail/PostmanTransportRegistry.php
+++ b/Postman/Postman-Mail/PostmanTransportRegistry.php
@@ -234,7 +234,7 @@ class PostmanTransportRegistry {
return __( 'Postman is configured.', Postman::TEXT_DOMAIN );
}
} else {
- return '<div class="updated error otgs-is-dismissible settings-error notice is-dismissible" style="20px;">' . __( 'Postman is <em>not</em> configured and is mimicking out-of-the-box WordPress email delivery.', Postman::TEXT_DOMAIN ) . '</div>';
+ return __( 'Postman is <em>not</em> configured and is mimicking out-of-the-box WordPress email delivery.', Postman::TEXT_DOMAIN );
}
}
}
diff --git a/Postman/Postman.php b/Postman/Postman.php
index 7eb512a..153257b 100644
--- a/Postman/Postman.php
+++ b/Postman/Postman.php
@@ -117,6 +117,14 @@ class Postman {
'on_plugins_loaded',
) );
+ $active_plugins = (array) get_option( 'active_plugins', array() );
+ if ( in_array( 'sitepress-multilingual-cms/sitepress.php', $active_plugins ) && !get_option( 'postman_wpml_fixed' ) ) {
+ add_action( 'admin_notices', array( $this, 'post_smtp_wpml_admin_notice' ) );
+
+ // Temp: Just a quick solution, need to find a better option.
+ add_action( 'admin_init', array( $this, 'postman_fix_wpml' ) );
+ }
+
// hook on the wp_loaded event
add_action( 'wp_loaded', array(
$this,
@@ -136,6 +144,31 @@ class Postman {
) );
}
+ public function post_smtp_wpml_admin_notice() {
+ $class = 'notice notice-error';
+ $title = __( 'Post SMTP notice!', Postman::TEXT_DOMAIN );
+ $intro = __( 'WPML is installed and has a known bug with Post SMTP and few other plugins.', Postman::TEXT_DOMAIN );
+ $text = __( 'Click here to fix', Postman::TEXT_DOMAIN );
+ $message = '<br><a href="' . esc_url( add_query_arg( 'action', 'postman_fix_wpml', get_permalink() ) ) . '">' . $text . '</a>';
+
+ printf( '<div class="%1$s"><h2>%2$s</h2><p>%3$s</p><p>%4$s</p></div>', esc_attr( $class ), $title, $intro, $message );
+ }
+
+ public function postman_fix_wpml() {
+ if ( isset( $_GET['action'] ) && $_GET['action'] == 'postman_fix_wpml' ) {
+ $wpml_file_path = WP_PLUGIN_DIR . '/sitepress-multilingual-cms/inc/utilities/wpml-data-encryptor.class.php';
+
+ if ( file_exists( $wpml_file_path ) ) {
+ $content = file_get_contents( $wpml_file_path );
+ $content = str_replace( "require_once ABSPATH . '/wp-includes/pluggable.php';", "//require_once ABSPATH . '/wp-includes/pluggable.php';", $content );
+ file_put_contents( $wpml_file_path, $content );
+ }
+
+ update_option( 'postman_wpml_fixed', true );
+ wp_redirect( esc_url( remove_query_arg( 'action' ) ) );
+ }
+ }
+
/**
* Functions to execute on the plugins_loaded event
*
diff --git a/Postman/PostmanInstaller.php b/Postman/PostmanInstaller.php
index 812f122..4b2603b 100644
--- a/Postman/PostmanInstaller.php
+++ b/Postman/PostmanInstaller.php
@@ -42,7 +42,7 @@ class PostmanInstaller {
$this->addCapability();
}
- $this->add_activation_redirect();
+ //$this->add_activation_redirect();
}
function add_activation_redirect() {
@@ -52,7 +52,7 @@ class PostmanInstaller {
return; }
// Add the transient to redirect
- set_transient( '_post_activation_redirect', true, 30 );
+ //set_transient( '_post_activation_redirect', true, 30 );
}
/**
diff --git a/Postman/PostmanViewController.php b/Postman/PostmanViewController.php
index 60274dc..991ea8a 100644
--- a/Postman/PostmanViewController.php
+++ b/Postman/PostmanViewController.php
@@ -36,7 +36,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
// initialize the scripts, stylesheets and form fields
add_action( 'admin_init', array( $this, 'registerStylesAndScripts' ), 0 );
- add_action( 'admin_init', array( $this, 'do_activation_redirect' ) );
+ //add_action( 'admin_init', array( $this, 'do_activation_redirect' ) );
}
diff --git a/postman-smtp.php b/postman-smtp.php
index 6cac54f..0141e95 100644
--- a/postman-smtp.php
+++ b/postman-smtp.php
@@ -4,7 +4,7 @@
* Plugin Name: Post SMTP
* Plugin URI: https://wordpress.org/plugins/post-smtp/
* Description: Email not reliable? Post SMTP is the first and only WordPress SMTP plugin to implement OAuth 2.0 for Gmail, Hotmail and Yahoo Mail. Setup is a breeze with the Configuration Wizard and integrated Port Tester. Enjoy worry-free delivery even if your password changes!
- * Version: 1.7.10
+ * Version: 1.8
* Author: Jason Hendriks, Yehuda Hassine
* Text Domain: post-smtp
* Author URI: https://postmansmtp.com
@@ -71,5 +71,5 @@ function post_start( $startingMemory ) {
*/
function post_setupPostman() {
require_once 'Postman/Postman.php';
- $kevinCostner = new Postman( __FILE__, '1.7.10' );
+ $kevinCostner = new Postman( __FILE__, '1.8' );
}
diff --git a/readme.txt b/readme.txt
index b4507a4..f986b52 100644
--- a/readme.txt
+++ b/readme.txt
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@m
Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email, office365
Requires at least: 3.9
Tested up to: 4.9
-Stable tag: 1.7.10
+Stable tag: 1.8
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -283,6 +283,11 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a
== Changelog ==
+= 1.8 - 2017-12-24
+* New: Mailgun API integration
+* New: New filter controls
+* New: WPML conflict fix
+* Fix: Minor old bugs
= 1.7.10 - 2017-11-21 ==
* Fixed: bug while detecting transcript error