summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Postman/Postman-Mail/PostmanMailgunMailEngine.php9
-rw-r--r--Postman/Postman-Mail/PostmanMailgunTransport.php21
-rw-r--r--Postman/PostmanInputSanitizer.php1
-rw-r--r--Postman/PostmanOptions.php7
-rw-r--r--postman-smtp.php5
-rw-r--r--readme.txt13
6 files changed, 44 insertions, 12 deletions
diff --git a/Postman/Postman-Mail/PostmanMailgunMailEngine.php b/Postman/Postman-Mail/PostmanMailgunMailEngine.php
index 8258022..e874704 100644
--- a/Postman/Postman-Mail/PostmanMailgunMailEngine.php
+++ b/Postman/Postman-Mail/PostmanMailgunMailEngine.php
@@ -1,6 +1,8 @@
<?php
require_once 'mailgun/mailgun.php';
+
use Mailgun\Mailgun;
+use Mailgun\HttpClientConfigurator;
if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) {
@@ -18,6 +20,7 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) {
// the result
private $transcript;
+ private $api_endpoint;
private $apiKey;
private $domainName;
private $mailgunMessage;
@@ -48,6 +51,7 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) {
*/
public function send( PostmanMessage $message ) {
$options = PostmanOptions::getInstance();
+ $this->api_endpoint = ! is_null( $options->getMailgunRegion() ) ? 'https://api.eu.mailgun.net' : 'https://api.mailgun.net';
// add the Postman signature - append it to whatever the user may have set
if ( ! $options->isStealthModeEnabled() ) {
@@ -161,7 +165,10 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) {
$this->logger->debug( 'Sending mail' );
}
- $mg = Mailgun::create( $this->apiKey );
+ $configurator = new HttpClientConfigurator();
+ $configurator->setEndpoint( $this->api_endpoint . '/v3/'. $this->domainName .'/messages');
+ $configurator->setApiKey($this->apiKey);
+ $mg = Mailgun::configure($configurator);
// Make the call to the client.
$result = $this->processSend( $mg );
diff --git a/Postman/Postman-Mail/PostmanMailgunTransport.php b/Postman/Postman-Mail/PostmanMailgunTransport.php
index 9a5e9d2..dcbc1ae 100644
--- a/Postman/Postman-Mail/PostmanMailgunTransport.php
+++ b/Postman/Postman-Mail/PostmanMailgunTransport.php
@@ -9,6 +9,7 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
const SLUG = 'mailgun_api';
const PORT = 443;
const HOST = 'api.mailgun.net';
+ const EU_REGION = 'api.eu.mailgun.net';
const PRIORITY = 8000;
const MAILGUN_AUTH_OPTIONS = 'postman_mailgun_auth_options';
const MAILGUN_AUTH_SECTION = 'postman_mailgun_auth_section';
@@ -43,7 +44,7 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
* @return string
*/
public function getHostname() {
- return self::HOST;
+ return ! is_null( $this->options->getMailgunRegion() ) ? self::EU_REGION : self::HOST;
}
/**
* v0.2.1
@@ -128,10 +129,10 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
$recommendation ['transport'] = self::SLUG;
$recommendation ['hostname'] = null; // scribe looks this
$recommendation ['label'] = $this->getName();
- if ( $hostData->hostname == self::HOST && $hostData->port == self::PORT ) {
+ if ( $hostData->hostname == $this->getHostname() && $hostData->port == self::PORT ) {
$recommendation ['priority'] = self::PRIORITY;
/* translators: where variables are (1) transport name (2) host and (3) port */
- $recommendation ['message'] = sprintf( __( ('Postman recommends the %1$s to host %2$s on port %3$d.') ), $this->getName(), self::HOST, self::PORT );
+ $recommendation ['message'] = sprintf( __( ('Postman recommends the %1$s to host %2$s on port %3$d.') ), $this->getName(), $this->getHostname(), self::PORT );
}
return $recommendation;
}
@@ -197,6 +198,11 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
$this,
'mailgun_domain_name_callback',
), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS, PostmanMailgunTransport::MAILGUN_AUTH_SECTION );
+
+ add_settings_field( PostmanOptions::MAILGUN_REGION, __( 'Mailgun Europe Region?', Postman::TEXT_DOMAIN ), array(
+ $this,
+ 'mailgun_region_callback',
+ ), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS, PostmanMailgunTransport::MAILGUN_AUTH_SECTION );
}
public function printMailgunAuthSectionInfo() {
/* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */
@@ -214,6 +220,11 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
printf( '<input type="text" autocomplete="off" id="mailgun_domain_name" name="postman_options[mailgun_domain_name]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMailgunDomainName() ? esc_attr( $this->options->getMailgunDomainName() ) : '', __( 'Required', Postman::TEXT_DOMAIN ) );
}
+ function mailgun_region_callback() {
+ $value = $this->options->getMailgunRegion();
+ printf( '<input type="checkbox" id="mailgun_region" name="postman_options[mailgun_region]"%s />', null !== $value ? ' checked' : '' );
+ }
+
/**
*/
public function registerStylesAndScripts() {
@@ -243,6 +254,10 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
printf( '<label for="domain_name">%s</label>', __( 'Domain Name', Postman::TEXT_DOMAIN ) );
print '<br />';
print $this->mailgun_domain_name_callback();
+ print '<br />';
+ printf( '<label for="mailgun_region">%s</label>', __( 'Mailgun Europe Region?', Postman::TEXT_DOMAIN ) );
+ print '<br />';
+ print $this->mailgun_region_callback();
print '</section>';
}
}
diff --git a/Postman/PostmanInputSanitizer.php b/Postman/PostmanInputSanitizer.php
index 859e3cb..b17df30 100644
--- a/Postman/PostmanInputSanitizer.php
+++ b/Postman/PostmanInputSanitizer.php
@@ -54,6 +54,7 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) {
$this->sanitizeString( 'From Name Override', PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, $input, $new_input );
$this->sanitizeString( 'From Email Override', PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, $input, $new_input );
$this->sanitizeString( 'Disable Email Validation', PostmanOptions::DISABLE_EMAIL_VALIDAITON, $input, $new_input );
+ $this->sanitizeString( 'Mailgun Europe Region', PostmanOptions::MAILGUN_REGION, $input, $new_input );
$this->sanitizeString( 'Forced To Recipients', PostmanOptions::FORCED_TO_RECIPIENTS, $input, $new_input );
$this->sanitizeString( 'Forced CC Recipients', PostmanOptions::FORCED_CC_RECIPIENTS, $input, $new_input );
$this->sanitizeString( 'Forced BCC Recipients', PostmanOptions::FORCED_BCC_RECIPIENTS, $input, $new_input );
diff --git a/Postman/PostmanOptions.php b/Postman/PostmanOptions.php
index 240b1aa..9c244bd 100644
--- a/Postman/PostmanOptions.php
+++ b/Postman/PostmanOptions.php
@@ -87,6 +87,7 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
const SENDGRID_API_KEY = 'sendgrid_api_key';
const MAILGUN_API_KEY = 'mailgun_api_key';
const MAILGUN_DOMAIN_NAME = 'mailgun_domain_name';
+ const MAILGUN_REGION = 'mailgun_region';
const PREVENT_MESSAGE_SENDER_NAME_OVERRIDE = 'prevent_sender_name_override';
const PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE = 'prevent_sender_email_override';
const CONNECTION_TIMEOUT = 'connection_timeout';
@@ -317,6 +318,12 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
}
}
+ public function getMailgunRegion() {
+ if ( isset( $this->options [ PostmanOptions::MAILGUN_REGION ] ) ) {
+ return $this->options [ PostmanOptions::MAILGUN_REGION ];
+ }
+ }
+
public function getPushoverUser() {
if ( isset( $this->options [ PostmanOptions::PUSHOVER_USER ] ) ) {
return base64_decode( $this->options [ PostmanOptions::PUSHOVER_USER ] );
diff --git a/postman-smtp.php b/postman-smtp.php
index cf29a7e..bd0f639 100644
--- a/postman-smtp.php
+++ b/postman-smtp.php
@@ -1,10 +1,9 @@
<?php
-
/*
* 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.9.4
+ * Version: 1.9.5
* Author: Jason Hendriks, Yehuda Hassine
* Text Domain: post-smtp
* Author URI: https://postmansmtp.com
@@ -123,5 +122,5 @@ function post_start( $startingMemory ) {
*/
function post_setupPostman() {
require_once 'Postman/Postman.php';
- $kevinCostner = new Postman( __FILE__, '1.9.4' );
+ $kevinCostner = new Postman( __FILE__, '1.9.5' );
}
diff --git a/readme.txt b/readme.txt
index d59717f..a8b18c5 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,10 +1,10 @@
=== Post SMTP Mailer/Email Log ===
-Contributors: yehudah, abdullahramzan ,jasonhendriks
+Contributors: yehudah ,jasonhendriks
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+PostSMTP
Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email, office365, mailgun
Requires at least: 3.9
-Tested up to: 4.9.5
-Stable tag: 1.9.4
+Tested up to: 4.9.8
+Stable tag: 1.9.5
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -12,8 +12,8 @@ Send, log and troubleshoot your Outgoing Email easily. Supports everything: SMTP
== Description ==
-= Version 1.9.4 released - A MUST READ FOR EXISTING USERS =
-I tryed to do stuff simple and I just the did opposite. [Read the detailes here](https://postmansmtp.com/post-smtp-1-9-4-im-only-human/)
+= Version 1.9.5 released =
+Support for Mailgun europe region API.
= WordPress Mail SMTP Plugin =
@@ -296,6 +296,9 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a
== Changelog ==
+= 1.9.5 - 2018-08-08
+Support for Mailgun Europe Region
+
= 1.9.4 - 2018-08-03
The most stupid idea ever remove (auto security select)