summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Postman/Phpmailer/PhpmailerInit.php169
-rw-r--r--Postman/Phpmailer/PostsmtpMailer.php103
-rw-r--r--Postman/Postman-Configuration/PostmanConfigurationController.php15
-rw-r--r--Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php6
-rw-r--r--Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php13
-rw-r--r--Postman/Postman-Email-Log/PostmanEmailLogController.php1
-rw-r--r--Postman/Postman-Mail/PostmanSmtpModuleTransport.php18
-rw-r--r--Postman/Postman.php19
-rw-r--r--Postman/PostmanInputSanitizer.php1
-rw-r--r--Postman/PostmanInstaller.php2
-rw-r--r--Postman/PostmanOptions.php14
-rw-r--r--Postman/PostmanViewController.php20
-rw-r--r--Postman/PostmanWpMail.php20
-rw-r--r--Postman/PostmanWpMailBinder.php2
-rw-r--r--Postman/extra/donation.php19
-rw-r--r--postman-smtp.php3
-rw-r--r--script/postman.js12
-rw-r--r--style/jquery-steps/jquery.steps.css1
-rw-r--r--style/postman.css4
19 files changed, 399 insertions, 43 deletions
diff --git a/Postman/Phpmailer/PhpmailerInit.php b/Postman/Phpmailer/PhpmailerInit.php
new file mode 100644
index 0000000..60d27f2
--- /dev/null
+++ b/Postman/Phpmailer/PhpmailerInit.php
@@ -0,0 +1,169 @@
+<?php
+
+class PhpmailerInit {
+
+ /**
+ * @var array
+ */
+ private $mail_error;
+
+ /**
+ * @var
+ */
+ private $transcript;
+
+ /**
+ * @var PostmanMessage
+ */
+ private $message;
+
+ /**
+ * @var PostmanOptions
+ */
+ private $options;
+
+ /**
+ * PhpmailerInit constructor.
+ */
+ public function __construct()
+ {
+ $this->set_vars();
+ $this->hooks();
+ }
+
+ public function set_vars() {
+ $this->options = PostmanOptions::getInstance();
+ }
+
+ public function hooks()
+ {
+ add_action( 'phpmailer_init', [ $this, 'phpmailer_init'] );
+ add_action( 'wp_mail_failed', [ $this, 'wp_mail_failed' ] );
+ add_filter( 'postman_wp_mail_result', [ $this, 'postman_wp_mail_result'] );
+ }
+
+ /**
+ * @param PHPMailer $mailer
+ */
+ public function phpmailer_init($mailer) {
+
+ if ( $this->options->getTransportType() !== 'smtp' ) {
+ return $mailer;
+ }
+
+ $mailer->SMTPDebug = 2;
+ $mailer->isSMTP();
+ $mailer->Host = $this->options->getHostname();
+ $mailer->SMTPAuth = $this->options->getAuthenticationType() !== 'none';
+ $mailer->AuthType = $this->options->getAuthenticationType() !== 'none' ? $this->options->getAuthenticationType() : '';
+ $mailer->Port = $this->options->getPort();
+ $mailer->Username = $this->options->getUsername();
+ $mailer->Password = $this->options->getPassword();
+ $mailer->SMTPSecure = $this->options->getEncryptionType();
+ $mailer->Debugoutput = function($str, $level) {
+ $this->transcript = $str;
+ };
+
+ $this->build_message($mailer);
+ }
+
+ /**
+ * @param PHPMailer $mailer
+ * @throws Exception
+ */
+ private function build_message($mailer) {
+ require_once dirname(__DIR__) . '/PostmanWpMail.php';
+
+ // create a PostmanWpMail instance
+ $postmanWpMail = new PostmanWpMail();
+ $postmanWpMail->init();
+
+ $senderEmail = $this->options->getMessageSenderEmail();
+ $senderName = $this->options->getMessageSenderName();
+
+ // create a PostmanMessage instance
+ $this->message = $postmanWpMail->createNewMessage();
+
+ $this->message->setFrom( $senderEmail, $senderName );
+ $this->message->addHeaders( $mailer->getCustomHeaders() );
+ $this->message->setBodyTextPart( $mailer->AltBody );
+ $this->message->setBodyHtmlPart( $mailer->Body );
+ $this->message->setBody( $mailer->AltBody . $mailer->Body );
+ $this->message->setSubject( $mailer->Subject );
+ $this->message->addTo( $this->flatArray($mailer->getToAddresses() ) );
+ $this->message->addCc( $this->flatArray($mailer->getCcAddresses() ) );
+ $this->message->addBCc( $this->flatArray( $mailer->getBccAddresses() ) );
+ $this->message->setReplyTo( $this->flatArray( $mailer->getReplyToAddresses() ) );
+ $this->message->setAttachments( $mailer->getAttachments() );
+ }
+
+ private function flatArray($arr) {
+ $result = [];
+ foreach ( $arr as $key => $value ) {
+ if ( is_array( $value ) ) {
+ foreach ($value as $k => $v ) {
+ $value = $v;
+ }
+ }
+
+ $result[] = $value;
+ }
+
+ return $result;
+ }
+
+ /**
+ * @param WP_Error $error
+ */
+ public function wp_mail_failed( $error ) {
+ $error_code = 0;
+ $error_message = $error->get_error_message();
+
+ $e = new Exception( $error_message, $error_code );
+ $this->mail_error = [
+ 'time' => null,
+ 'exception' => $e,
+ 'transcript' => $this->transcript
+ ];
+
+ $this->save_log( $error );
+ $this->check_fallback( $error->get_error_data() );
+ }
+
+ private function check_fallback( $data ) {
+ if ( ! $this->options->is_fallback ) {
+ $this->options->is_fallback = true;
+ extract( $data );
+
+ wp_mail( $to, $subject, $message, $headers, $attachments );
+ } else {
+ $this->options->is_fallback = false;
+ }
+ }
+
+ /**
+ * @param WP_Error $error
+ */
+ private function save_log( $error ) {
+ require_once dirname(__DIR__) . '/Postman-Email-Log/PostmanEmailLogService.php';
+
+ $data = $error->get_error_data();
+
+ // build the email log entry
+ $log = new PostmanEmailLog();
+ $log->success = false;
+ $log->originalTo = $data['to'];
+ $log->originalSubject = $data['subject'];
+ $log->originalMessage = $data['message'];
+ $log->originalHeaders = $data['headers'];
+ $log->statusMessage = $error->get_error_message();
+ $log->sessionTranscript = $this->transcript;
+
+ PostmanEmailLogService::getInstance()->writeFailureLog( $log, $this->message, $this->transcript, new PostmanSmtpModuleTransport(POST_BASE), $error->get_error_message() );
+ }
+
+ public function postman_wp_mail_result() {
+ return $this->mail_error;
+ }
+}
+new PhpmailerInit(); \ No newline at end of file
diff --git a/Postman/Phpmailer/PostsmtpMailer.php b/Postman/Phpmailer/PostsmtpMailer.php
new file mode 100644
index 0000000..b41b43c
--- /dev/null
+++ b/Postman/Phpmailer/PostsmtpMailer.php
@@ -0,0 +1,103 @@
+<?php
+require_once ABSPATH . WPINC . '/class-phpmailer.php';
+require_once ABSPATH . WPINC . '/class-smtp.php';
+
+add_action('plugins_loaded', function() {
+ global $phpmailer;
+
+ $phpmailer = new PostsmtpMailer(true);
+});
+
+class PostsmtpMailer extends PHPMailer {
+
+ private $options;
+
+ private $error;
+
+ public function __construct($exceptions = null)
+ {
+ parent::__construct($exceptions);
+
+ $this->options = PostmanOptions::getInstance();
+ add_filter( 'postman_wp_mail_result', [ $this, 'postman_wp_mail_result' ] );
+ }
+
+ public function send()
+ {
+ require_once dirname(__DIR__) . '/PostmanWpMail.php';
+
+ // create a PostmanWpMail instance
+ $postmanWpMail = new PostmanWpMail();
+ $postmanWpMail->init();
+
+ $senderEmail = $this->options->getMessageSenderEmail();
+ $senderName = $this->options->getMessageSenderName();
+
+ $this->addCustomHeader('X-Mailer', 'PostSMTP/' . POST_SMTP_VER );
+
+ // create a PostmanMessage instance
+ $message = $postmanWpMail->createNewMessage();
+
+ $message->setFrom( $senderEmail, $senderName );
+ $message->addHeaders( $this->getCustomHeaders() );
+ $message->setBodyTextPart( $this->AltBody );
+ $message->setBodyHtmlPart( $this->Body );
+ $message->setBody( $this->Body );
+ $message->setSubject( $this->Subject );
+ $message->addTo( $this->flatArray($this->getToAddresses() ) );
+ $message->setReplyTo( $this->flatArray( $this->getReplyToAddresses() ) );
+ $message->addCc( $this->flatArray($this->getCcAddresses() ) );
+ $message->addBCc( $this->flatArray( $this->getBccAddresses() ) );
+ $message->setReplyTo( $this->flatArray( $this->getReplyToAddresses() ) );
+ $message->setAttachments( $this->getAttachments() );
+
+ // create a PostmanEmailLog instance
+ $log = new PostmanEmailLog();
+
+ $log->originalTo = $this->flatArray($this->getToAddresses() );
+ $log->originalSubject = $this->Subject;
+ $log->originalMessage = $this->Body;
+ $log->originalHeaders = $this->getCustomHeaders();
+
+ try {
+ return $postmanWpMail->sendMessage( $message, $log );
+ } catch (phpmailerException $exc) {
+
+ $this->error = $exc;
+
+ $this->mailHeader = '';
+ $this->setError($exc->getMessage());
+ if ($this->exceptions) {
+ throw $exc;
+ }
+ return false;
+ }
+
+ }
+
+ public function postman_wp_mail_result() {
+ $result = [
+ 'exception' => $this->error,
+ 'transcript' => '',
+ ];
+ return $result;
+ }
+
+ private function flatArray($arr) {
+ $result = [];
+ foreach ( $arr as $key => $value ) {
+ if ( is_array( $value ) ) {
+ foreach ($value as $k => $v ) {
+ if ( empty( $v ) ) {
+ continue;
+ }
+ $value = $v;
+ }
+ }
+
+ $result[] = $value;
+ }
+
+ return implode(',', $result );
+ }
+} \ No newline at end of file
diff --git a/Postman/Postman-Configuration/PostmanConfigurationController.php b/Postman/Postman-Configuration/PostmanConfigurationController.php
index d2c0350..98e1bac 100644
--- a/Postman/Postman-Configuration/PostmanConfigurationController.php
+++ b/Postman/Postman-Configuration/PostmanConfigurationController.php
@@ -591,17 +591,10 @@ class PostmanConfigurationController {
printf( '<li class="wizard-auth-oauth2">%s</li>', __( 'Grant permission with the Email Provider for Postman to send email and', 'post-smtp' ) );
printf( '<li>%s</li>', __( 'Send yourself a Test Email to make sure everything is working!', 'post-smtp' ) );
print '</ul>';
- ?>
- <p>It is hard to continue development and support for this free plugin without contributions from users like you.
- If you enjoy using Post SMTP and find it useful, please consider making a donation. Your donation will
- help encourage and support the plugin's continued development and better user support.</p>
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
- <input type="hidden" name="cmd" value="_s-xclick" />
- <input type="hidden" name="hosted_button_id" value="4B3PJANHBA7MG" />
- <input type="image" src="https://www.paypalobjects.com/en_US/IL/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
- <img alt="" border="0" src="https://www.paypal.com/en_IL/i/scr/pixel.gif" width="1" height="1" />
- </form>
- <?php
+
+ $in_wizard = true;
+ include_once POST_PATH . '/Postman/extra/donation.php';
+
print '</section>';
print '</fieldset>';
print '</form>';
diff --git a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
index a23094f..e62d430 100644
--- a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
+++ b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
@@ -34,9 +34,9 @@ class PostmanSettingsRegistry {
), 'transport_options' );
add_settings_field( PostmanOptions::TRANSPORT_TYPE, _x( 'Type', '(i.e.) What kind is it?', 'post-smtp' ), array(
- $this,
- 'transport_type_callback',
- ), 'transport_options', 'transport_section' );
+ $this,
+ 'transport_type_callback',
+ ), 'transport_options', 'transport_section' );
// the Message From section
add_settings_section( PostmanAdminController::MESSAGE_FROM_SECTION, _x( 'From Address', 'The Message Sender Email Address', 'post-smtp' ), array(
diff --git a/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php b/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php
index 6eeda60..82eb558 100644
--- a/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php
+++ b/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php
@@ -210,6 +210,7 @@ class PostmanGetDiagnosticsViaAjax {
public function getDiagnostics() {
$curl = curl_version();
$transportRegistry = PostmanTransportRegistry::getInstance();
+ $this->addToDiagnostics( 'Mailer', PostmanOptions::getInstance()->getSmtpMailer() );
$this->addToDiagnostics( 'HostName', PostmanUtils::getServerName() );
$this->addToDiagnostics( 'cURL Version', $curl['version'] );
$this->addToDiagnostics( 'OpenSSL Version', $curl['ssl_version'] );
@@ -219,17 +220,15 @@ class PostmanGetDiagnosticsViaAjax {
$this->addToDiagnostics( 'WordPress', (is_multisite() ? 'Multisite ' : '') . get_bloginfo( 'version' ) . ' ' . get_locale() . ' ' . get_bloginfo( 'charset', 'display' ) );
$this->addToDiagnostics( 'WordPress Theme', wp_get_theme() );
$this->addToDiagnostics( 'WordPress Plugins', $this->getActivePlugins() );
- {
- $bindResult = apply_filters( 'postman_wp_mail_bind_status', null );
- $wp_mail_file_name = 'n/a';
+
+ $bindResult = apply_filters( 'postman_wp_mail_bind_status', null );
+ $wp_mail_file_name = 'n/a';
if ( class_exists( 'ReflectionFunction' ) ) {
$wp_mail = new ReflectionFunction( 'wp_mail' );
$wp_mail_file_name = realpath( $wp_mail->getFileName() );
}
- if ( ! $bindResult ['bound'] ) {
- $this->addToDiagnostics( 'WordPress wp_mail Owner', $wp_mail_file_name );
- }
- }
+
+ $this->addToDiagnostics( 'WordPress wp_mail Owner', $wp_mail_file_name );
$this->addToDiagnostics( 'WordPress wp_mail Filter(s)', $this->getFilters( 'wp_mail' ) );
$this->addToDiagnostics( 'WordPress wp_mail_from Filter(s)', $this->getFilters( 'wp_mail_from' ) );
$this->addToDiagnostics( 'WordPress wp_mail_from_name Filter(s)', $this->getFilters( 'wp_mail_from_name' ) );
diff --git a/Postman/Postman-Email-Log/PostmanEmailLogController.php b/Postman/Postman-Email-Log/PostmanEmailLogController.php
index f625a82..2845967 100644
--- a/Postman/Postman-Email-Log/PostmanEmailLogController.php
+++ b/Postman/Postman-Email-Log/PostmanEmailLogController.php
@@ -78,7 +78,6 @@ class PostmanEmailLogController {
// get the email address of the recipient from the HTTP Request
$postid = $this->getRequestParameter( 'email' );
if ( ! empty( $postid ) ) {
- $post = get_post( $postid );
$meta_values = PostmanEmailLogs::get_data( $postid );
if ( isset( $_POST['mail_to'] ) && ! empty( $_POST['mail_to'] ) ) {
diff --git a/Postman/Postman-Mail/PostmanSmtpModuleTransport.php b/Postman/Postman-Mail/PostmanSmtpModuleTransport.php
index 08e833f..b0fb2c3 100644
--- a/Postman/Postman-Mail/PostmanSmtpModuleTransport.php
+++ b/Postman/Postman-Mail/PostmanSmtpModuleTransport.php
@@ -327,6 +327,11 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
'printSmtpSectionInfo',
), PostmanAdminController::SMTP_OPTIONS );
+ add_settings_field( 'smtp_mailers', __( 'If you have any issues with the default, select PHPMailer', 'post-smtp' ), array(
+ $this,
+ 'smtp_mailer_callback',
+ ), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION );
+
add_settings_field( PostmanOptions::HOSTNAME, __( 'Outgoing Mail Server Hostname', 'post-smtp' ), array(
$this,
'hostname_callback',
@@ -401,6 +406,19 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
print __( 'Configure the communication with the mail server.', 'post-smtp' );
}
+ /**
+ * Get the settings option array and print one of its values
+ */
+ public function smtp_mailer_callback() {
+ $smtp_mailers = PostmanOptions::SMTP_MAILERS;
+ $current_smtp_mailer = $this->options->getSmtpMailer();
+ printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, 'smtp_mailers' );
+ foreach ( $smtp_mailers as $key => $smtp_mailer ) {
+ printf( '<option class="input_tx_type_%1$s" value="%1$s" %3$s>%2$s</option>', $key, $smtp_mailer, $current_smtp_mailer == $key ? 'selected="selected"' : '' );
+ }
+ print '</select>';
+ }
+
/**
* Get the settings option array and print one of its values
*/
diff --git a/Postman/Postman.php b/Postman/Postman.php
index 0c25d66..c832ef6 100644
--- a/Postman/Postman.php
+++ b/Postman/Postman.php
@@ -64,6 +64,7 @@ class Postman {
require_once 'Postman-Email-Log/PostmanEmailLogPostType.php';
require_once 'Postman-Mail/PostmanMyMailConnector.php';
require_once 'Postman-Mail/PostmanContactForm7.php';
+ require_once 'Phpmailer/PostsmtpMailer.php';
//require_once 'Postman-Mail/PostmanWooCommerce.php';
// get plugin metadata - alternative to get_plugin_data
@@ -91,13 +92,19 @@ class Postman {
// register the email transports
$this->registerTransports( $rootPluginFilenameAndPath );
- // store an instance of the WpMailBinder
- $this->wpMailBinder = PostmanWpMailBinder::getInstance();
+ // store an instance of the WpMailBinder
+ $this->wpMailBinder = PostmanWpMailBinder::getInstance();
- // bind to wp_mail - this has to happen before the "init" action
- // this design allows other plugins to register a Postman transport and call bind()
- // bind may be called more than once
- $this->wpMailBinder->bind();
+ $this->logger->trace( 'SMTP Mailer: ' . PostmanOptions::getInstance()->getSmtpMailer() );
+ PostmanWpMailBinder::getInstance()->bound = true;
+ if ( PostmanOptions::getInstance()->getTransportType() == 'smtp' &&
+ PostmanOptions::getInstance()->getSmtpMailer() !== 'phpmailer') {
+
+ // bind to wp_mail - this has to happen before the "init" action
+ // this design allows other plugins to register a Postman transport and call bind()
+ // bind may be called more than once
+ $this->wpMailBinder->bind();
+ }
// registers the custom post type for all callers
PostmanEmailLogPostType::automaticallyCreatePostType();
diff --git a/Postman/PostmanInputSanitizer.php b/Postman/PostmanInputSanitizer.php
index 66c2dd0..561ce28 100644
--- a/Postman/PostmanInputSanitizer.php
+++ b/Postman/PostmanInputSanitizer.php
@@ -40,6 +40,7 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) {
$new_input [ PostmanOptions::ENVELOPE_SENDER ] = $new_input [ PostmanOptions::MESSAGE_SENDER_EMAIL ];
$this->sanitizeString( 'Sender Email', PostmanOptions::ENVELOPE_SENDER, $input, $new_input );
$this->sanitizeString( 'Transport Type', PostmanOptions::TRANSPORT_TYPE, $input, $new_input );
+ $this->sanitizeString( 'SMTP Mailers', 'smtp_mailers', $input, $new_input );
$this->sanitizeString( 'Authorization Type', PostmanOptions::AUTHENTICATION_TYPE, $input, $new_input );
$this->sanitizeString( 'From Name', PostmanOptions::MESSAGE_SENDER_NAME, $input, $new_input );
$this->sanitizeString( 'Client ID', PostmanOptions::CLIENT_ID, $input, $new_input );
diff --git a/Postman/PostmanInstaller.php b/Postman/PostmanInstaller.php
index f3616f2..0563679 100644
--- a/Postman/PostmanInstaller.php
+++ b/Postman/PostmanInstaller.php
@@ -25,6 +25,8 @@ class PostmanInstaller {
*/
public function activatePostman() {
delete_option( 'postman_release_version' );
+ delete_option( 'postman_dismiss_donation' );
+
$options = get_option( PostmanOptions::POSTMAN_OPTIONS );
$args = array(
'fallback_smtp_enabled' => 'no',
diff --git a/Postman/PostmanOptions.php b/Postman/PostmanOptions.php
index 3beae34..7d8c2a0 100644
--- a/Postman/PostmanOptions.php
+++ b/Postman/PostmanOptions.php
@@ -138,6 +138,11 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
const DEFAULT_PLUGIN_MESSAGE_SENDER_EMAIL_ENFORCED = false;
const DEFAULT_TEMP_DIRECTORY = '/tmp';
+ const SMTP_MAILERS = [
+ 'phpmailer' => 'PHPMailer',
+ 'postsmtp' => 'PostSMTP'
+ ];
+
public $is_fallback = false;
// options data
@@ -569,6 +574,15 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
$this->setSenderName( $senderName );
}
}
+
+ public function getSmtpMailer() {
+ if ( empty($this->options [ 'smtp_mailers' ]) ) {
+ return 'postsmtp';
+ }
+
+ return $this->options [ 'smtp_mailers' ];
+ }
+
public function isAuthTypePassword() {
return $this->isAuthTypeLogin() || $this->isAuthTypeCrammd5() || $this->isAuthTypePlain();
}
diff --git a/Postman/PostmanViewController.php b/Postman/PostmanViewController.php
index 0aa4370..4054f11 100644
--- a/Postman/PostmanViewController.php
+++ b/Postman/PostmanViewController.php
@@ -38,6 +38,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
add_action( 'admin_init', array( $this, 'registerStylesAndScripts' ), 0 );
add_action( 'wp_ajax_delete_lock_file', array( $this, 'delete_lock_file' ) );
add_action( 'wp_ajax_dismiss_version_notify', array( $this, 'dismiss_version_notify' ) );
+ add_action( 'wp_ajax_dismiss_donation_notify', array( $this, 'dismiss_donation_notify' ) );
//add_action( 'admin_init', array( $this, 'do_activation_redirect' ) );
@@ -47,10 +48,15 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
function dismiss_version_notify() {
check_ajax_referer( 'postsmtp', 'security' );
- $version = sanitize_text_field($_POST['version']);
$result = update_option('postman_release_version', true );
}
+ function dismiss_donation_notify() {
+ check_ajax_referer( 'postsmtp', 'security' );
+
+ $result = update_option('postman_dismiss_donation', true );
+ }
+
function delete_lock_file() {
check_ajax_referer( 'postman', 'security' );
@@ -213,7 +219,12 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
}
printf( '<p><span>%s :-)</span></p>', sprintf( __( 'Postman needs translators! Please take a moment to <a href="%s">translate a few sentences on-line</a>', 'post-smtp' ), 'https://translate.wordpress.org/projects/wp-plugins/post-smtp/stable' ) );
}
- printf( '<p><span>%s</span></p>', __( '<b style="background-color:yellow">New for v1.7!</style></b> Send mail with the Mandrill or SendGrid APIs.', 'post-smtp' ) );
+ printf(
+ '<p><span>%s</span>&nbsp;<a target="_blank" href="%s">%s</a></p>',
+ __( '<b style="background-color:yellow">New for v1.9.8!</b> Fallback - setup a second delivery method when the first one is failing', 'post-smtp' ),
+ 'https://postmansmtp.com/post-smtp-1-9-7-the-smtp-fallback/',
+ __( 'Check the detailes here', 'post-smtp')
+ );
}
/**
@@ -316,6 +327,9 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
</button>
</div>';
}
+
+ include_once POST_PATH . '/Postman/extra/donation.php';
+
echo '<div class="twitter-wrap">';
print '<div id="postman-main-menu" class="welcome-panel">';
print '<div class="welcome-panel-content">';
@@ -361,7 +375,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
printf( '<li><img class="align-middle" src="' . plugins_url( 'style/images/new.gif', dirname( __DIR__ ) . '/postman-smtp.php' ) . '"><a target="blank" class="align-middle" href="https://postmansmtp.com/category/guides/" class="welcome-icon postman_guides">%s</a></li>', __( 'Guides', 'post-smtp' ) );
print '</ul></div></div></div></div>';
?>
- <div class="twitter-iframe-wrap">
+ <div class="twitter-iframe-wrap" style="min-width: 300px;">
<a class="twitter-timeline" data-height="304" href="https://twitter.com/PostSMTP?ref_src=twsrc%5Etfw">Tweets by PostSMTP</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
</div>
diff --git a/Postman/PostmanWpMail.php b/Postman/PostmanWpMail.php
index 41586b4..3d1f8f5 100644
--- a/Postman/PostmanWpMail.php
+++ b/Postman/PostmanWpMail.php
@@ -1,4 +1,5 @@
<?php
+
if ( ! class_exists( 'PostmanWpMail' ) ) {
/**
@@ -45,9 +46,6 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
$headers = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
}
- // Apply critical headers
- $headers = $this->apply_default_headers( (array)$headers );
-
// build the message
$postmanMessage = $this->processWpMailCall( $to, $subject, $message, $headers, $attachments );
@@ -63,14 +61,15 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
}
/**
- * @param array $headers
- * @return array $headers
+ * @param PostmanMessage $message
+ * @return PostmanMessage
*/
- private function apply_default_headers( $headers ) {
-
+ private function apply_default_headers( $message ) {
+ $headers = $message->getHeaders();
$headers[] = 'Message-ID: ' . $this->createMessageId();
+ $message->addHeaders($headers);
- return $headers;
+ return $message;
}
/**
@@ -183,6 +182,8 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
*/
public function sendMessage( PostmanMessage $message, PostmanEmailLog $log ) {
+ $message = $this->apply_default_headers( $message );
+
// get the Options and AuthToken
$options = PostmanOptions::getInstance();
$authorizationToken = PostmanOAuthToken::getInstance();
@@ -290,6 +291,9 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );
// return failure
+ if ( PostmanOptions::getInstance()->getSmtpMailer() == 'phpmailer' ) {
+ throw new phpmailerException($e->getMessage(), $e->getCode());
+ }
return false;
}
diff --git a/Postman/PostmanWpMailBinder.php b/Postman/PostmanWpMailBinder.php
index 21d14e0..95eb898 100644
--- a/Postman/PostmanWpMailBinder.php
+++ b/Postman/PostmanWpMailBinder.php
@@ -2,7 +2,7 @@
if (! class_exists ( 'PostmanWpMailBinder' )) {
class PostmanWpMailBinder {
private $logger;
- private $bound;
+ public $bound;
private $bindError;
/**
diff --git a/Postman/extra/donation.php b/Postman/extra/donation.php
new file mode 100644
index 0000000..bee1980
--- /dev/null
+++ b/Postman/extra/donation.php
@@ -0,0 +1,19 @@
+<?php
+$postman_dismiss_donation = get_option('postman_dismiss_donation');
+
+if ( empty( $postman_dismiss_donation ) || $in_wizard ) : ?>
+ <div class="updated settings-error notice is-dismissible post-smtp-donation">
+ <p style="font-size: 1.1em;">It is hard to continue development and support for this free plugin without contributions from users like you.<br>
+ If you enjoy using <strong>Post SMTP</strong> and find it useful, please consider making a donation.<br>
+ Your donation will help encourage and support the plugin's continued development and better user support.</p>
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
+ <input type="hidden" name="cmd" value="_s-xclick" />
+ <input type="hidden" name="hosted_button_id" value="4B3PJANHBA7MG" />
+ <input type="image" src="https://www.paypalobjects.com/en_US/IL/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
+ <img alt="" border="0" src="https://www.paypal.com/en_IL/i/scr/pixel.gif" width="1" height="1" />
+ </form>
+ <button style="z-index: 100;" data-security="<?php echo wp_create_nonce('postsmtp'); ?>" type="button" class="notice-dismiss donation-dismiss">
+ <span class="screen-reader-text">Dismiss this notice.</span>
+ </button>
+ </div>
+<?php endif; ?> \ No newline at end of file
diff --git a/postman-smtp.php b/postman-smtp.php
index 1434fd0..d1c4bfc 100644
--- a/postman-smtp.php
+++ b/postman-smtp.php
@@ -40,6 +40,7 @@
define( 'POST_BASE', __FILE__ );
define( 'POST_PATH', __DIR__ );
+define( 'POST_SMTP_VER', '1.9.8' );
$postman_smtp_exist = in_array( 'postman-smtp/postman-smtp.php', (array) get_option( 'active_plugins', array() ) );
$required_php_version = version_compare( PHP_VERSION, '5.6.0', '<' );
@@ -126,5 +127,5 @@ function post_start( $startingMemory ) {
*/
function post_setupPostman() {
require_once 'Postman/Postman.php';
- $kevinCostner = new Postman( __FILE__, '1.9.8' );
+ $kevinCostner = new Postman( __FILE__, POST_SMTP_VER );
}
diff --git a/script/postman.js b/script/postman.js
index 0134430..edd33ac 100644
--- a/script/postman.js
+++ b/script/postman.js
@@ -14,6 +14,18 @@ jQuery(document).ready(function($) {
});
});
+ $('.post-smtp-donation .donation-dismiss').on('click', function() {
+ var $this = $(this);
+ var args = {
+ action: 'dismiss_donation_notify',
+ security: $this.data('security'),
+ };
+
+ $.post(ajaxurl, args, function() {
+ $this.parent().slideUp();
+ });
+ });
+
$('#postman_trash_all').on('click',function(e) {
if (confirm("Are You Sure?") == false) {
e.preventDefault();
diff --git a/style/jquery-steps/jquery.steps.css b/style/jquery-steps/jquery.steps.css
index 0a2e58b..ac157c7 100644
--- a/style/jquery-steps/jquery.steps.css
+++ b/style/jquery-steps/jquery.steps.css
@@ -163,7 +163,6 @@
.wizard > .content > .body
{
float: left;
- position: absolute;
width: 95%;
height: 95%;
padding: 2.5%;
diff --git a/style/postman.css b/style/postman.css
index 2366e10..7e314a4 100644
--- a/style/postman.css
+++ b/style/postman.css
@@ -19,6 +19,7 @@
#postman-main-menu.welcome-panel {
padding: 0px 10px 5px;
+ overflow: hidden;
}
#postman-main-menu.advanced_config {
@@ -93,7 +94,8 @@ dt em {
p#back_to_main_menu {
text-align: right;
- margin-top: 10px
+ margin-top: 10px;
+ padding-right: 10px;
}
.welcome-panel-column welcome-panel-last {