summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Postman/Postman-Configuration/PostmanConfigurationController.php113
-rw-r--r--Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php6
-rw-r--r--Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php4
-rw-r--r--Postman/Postman-Email-Log/PostmanEmailLogController.php2
-rw-r--r--Postman/Postman-Email-Log/PostmanEmailLogService.php41
-rw-r--r--Postman/Postman-Mail/PostmanMyMailConnector.php44
-rw-r--r--Postman/Postman-Mail/PostmanSendGridMailEngine.php1
-rw-r--r--Postman/Postman-Mail/mailchimp-mandrill-api-php-da3adc10042e/src/Mandrill.php2
-rw-r--r--Postman/Postman.php1
-rw-r--r--Postman/PostmanAdminController.php73
-rw-r--r--Postman/PostmanInputSanitizer.php11
-rw-r--r--Postman/PostmanInstaller.php39
-rw-r--r--Postman/PostmanOptions.php164
-rw-r--r--Postman/PostmanUtils.php5
-rw-r--r--Postman/PostmanViewController.php4
-rw-r--r--Postman/PostmanWpMail.php27
-rw-r--r--postman-smtp.php12
-rw-r--r--readme.txt20
18 files changed, 507 insertions, 62 deletions
diff --git a/Postman/Postman-Configuration/PostmanConfigurationController.php b/Postman/Postman-Configuration/PostmanConfigurationController.php
index 208fa0b..1e5b0a3 100644
--- a/Postman/Postman-Configuration/PostmanConfigurationController.php
+++ b/Postman/Postman-Configuration/PostmanConfigurationController.php
@@ -197,14 +197,18 @@ class PostmanConfigurationController {
PostmanViewController::outputChildPageHeader( __( 'Settings', Postman::TEXT_DOMAIN ), 'advanced_config' );
print '<div id="config_tabs"><ul>';
print sprintf( '<li><a href="#account_config">%s</a></li>', __( 'Account', Postman::TEXT_DOMAIN ) );
+ print sprintf( '<li><a href="#fallback">%s</a></li>', __( 'Fallback', Postman::TEXT_DOMAIN ) );
print sprintf( '<li><a href="#message_config">%s</a></li>', __( 'Message', Postman::TEXT_DOMAIN ) );
print sprintf( '<li><a href="#logging_config">%s</a></li>', __( 'Logging', Postman::TEXT_DOMAIN ) );
print sprintf( '<li><a href="#advanced_options_config">%s</a></li>', __( 'Advanced', Postman::TEXT_DOMAIN ) );
print sprintf( '<li><a href="#notifications">%s</a></li>', __( 'Notifications', Postman::TEXT_DOMAIN ) );
print '</ul>';
+
print '<form method="post" action="options.php">';
// This prints out all hidden setting fields
settings_fields( PostmanAdminController::SETTINGS_GROUP_NAME );
+
+ // account_config
print '<section id="account_config">';
if ( sizeof( PostmanTransportRegistry::getInstance()->getTransports() ) > 1 ) {
do_settings_sections( 'transport_options' );
@@ -230,6 +234,115 @@ class PostmanConfigurationController {
do_settings_sections( PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS );
print '</div>';
print '</section>';
+ // end account config
+ ?>
+
+ <!-- Fallback Start -->
+ <section id="fallback">
+ <h2><?php esc_html_e( 'Failed emails fallback', Postman::TEXT_DOMAIN ); ?></h2>
+ <p><?php esc_html_e( 'By enable this option, if your email is fail to send Post SMTP will try to use the SMTP service you define here.', Postman::TEXT_DOMAIN ); ?></p>
+ <table class="form-table">
+ <tr valign="">
+ <th scope="row"><?php _e( 'Use Fallback?', Postman::TEXT_DOMAIN ); ?></th>
+ <td>
+ <label>
+ <input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_ENABLED; ?>]" type="radio"
+ value="no"<?php echo checked( $this->options->getFallbackIsEnabled(), 'no' ); ?>>
+ <?php _e( 'No', Postman::TEXT_DOMAIN ); ?>
+ </label>
+ &nbsp;
+ <label>
+ <?php $checked = checked( $this->options->getFallbackIsEnabled(), 'yes', false ); ?>
+ <input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_ENABLED; ?>]" type="radio"
+ value="yes"<?php echo checked( $this->options->getFallbackIsEnabled(), 'yes' ); ?>>
+ <?php _e( 'Yes', Postman::TEXT_DOMAIN ); ?>
+ </label>
+ </td>
+ </tr>
+
+ <tr>
+ <th scope="row"><?php _e('Outgoing Mail Server', Postman::TEXT_DOMAIN ); ?></th>
+ <?php $host = $this->options->getFallbackHostname(); ?>
+ <td>
+ <input type="text" id="fallback-smtp-host" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_HOSTNAME; ?>]"
+ value="<?php echo $host; ?>" placeholder="Example: smtp.host.com">
+ </td>
+ </tr>
+
+ <tr>
+ <th scope="row"><?php _e('Mail Server Port', Postman::TEXT_DOMAIN ); ?></th>
+ <?php $port = $this->options->getFallbackPort(); ?>
+ <td>
+ <input type="number" id="fallback-smtp-port" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_PORT; ?>]"
+ value="<?php echo $port; ?>" placeholder="Example: 587">
+ </td>
+ </tr>
+
+ <tr>
+ <th scope="row"><?php _e('Security', Postman::TEXT_DOMAIN ); ?></th>
+ <?php
+ $security_options = array(
+ 'none' => __( 'None', Postman::TEXT_DOMAIN ),
+ 'ssl' => __( 'SSL', Postman::TEXT_DOMAIN ),
+ 'tls' => __( 'TLS', Postman::TEXT_DOMAIN ),
+ );
+ ?>
+ <td>
+ <select id="fallback-smtp-security" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_SECURITY; ?>]">
+ <?php
+ foreach ( $security_options as $key => $label ) {
+ $selected = selected( $this->options->getFallbackSecurity(), $key,false );
+ ?>
+ <option value="<?php echo $key; ?>"<?php echo $selected; ?>><?php echo $label; ?></option>
+ <?php
+ }
+ ?>
+ </select>
+ </td>
+ </tr>
+
+ <tr valign="">
+ <th scope="row"><?php _e( 'Use SMTP Authentication?', Postman::TEXT_DOMAIN ); ?></th>
+ <td>
+ <label>
+ <input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USE_AUTH; ?>]"
+ type="radio" value="none"<?php checked( $this->options->getFallbackAuth(), 'none' ); ?>>
+ <?php _e( 'No', Postman::TEXT_DOMAIN ); ?>
+ </label>
+ &nbsp;
+ <label>
+ <input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USE_AUTH; ?>]"
+ type="radio" value="login"<?php checked( $this->options->getFallbackAuth(), 'login' ); ?>>
+ <?php _e( 'Yes', Postman::TEXT_DOMAIN ); ?>
+ </label>
+ </td>
+ </tr>
+
+ <tr>
+ <th scope="row"><?php _e('User name', Postman::TEXT_DOMAIN ); ?></th>
+ <td>
+ <input type="text" id="fallback-smtp-username"
+ value="<?php echo $this->options->getFallbackUsername(); ?>"
+ name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USERNAME; ?>]"
+ >
+ </td>
+ </tr>
+
+ <tr>
+ <th scope="row"><?php _e('Password', Postman::TEXT_DOMAIN ); ?></th>
+ <td>
+ <input type="password" id="fallback-smtp-password"
+ value="<?php echo PostmanUtils::obfuscatePassword( $this->options->getFallbackPassword() ); ?>"
+ name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_PASSWORD; ?>]"
+ >
+ </td>
+ </tr>
+
+ </table>
+ </section>
+ <!-- Fallback End -->
+
+ <?php
print '<section id="message_config">';
do_settings_sections( PostmanAdminController::MESSAGE_SENDER_OPTIONS );
do_settings_sections( PostmanAdminController::MESSAGE_FROM_OPTIONS );
diff --git a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
index 6102d10..7882d43 100644
--- a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
+++ b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
@@ -21,7 +21,7 @@ class PostmanSettingsRegistry {
// only administrators should be able to trigger this
if ( PostmanUtils::isAdmin() ) {
- $sanitizer = new PostmanInputSanitizer();
+ $sanitizer = new PostmanInputSanitizer();
register_setting( PostmanAdminController::SETTINGS_GROUP_NAME, PostmanOptions::POSTMAN_OPTIONS, array(
$sanitizer,
'sanitize',
@@ -101,6 +101,8 @@ class PostmanSettingsRegistry {
'headers_callback',
), PostmanAdminController::MESSAGE_HEADERS_OPTIONS, PostmanAdminController::MESSAGE_HEADERS_SECTION );
+ // Fallback
+
// the Email Validation section
add_settings_section( PostmanAdminController::EMAIL_VALIDATION_SECTION, __( 'Validation', Postman::TEXT_DOMAIN ), array(
$this,
@@ -431,7 +433,7 @@ class PostmanSettingsRegistry {
}
public function notification_chrome_uid_callback() {
- printf( '<input type="password" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_CHROME_UID, $this->options->getNotificationChromeUid() );
+ printf( '<input type="password" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_CHROME_UID, PostmanUtils::obfuscatePassword( $this->options->getNotificationChromeUid() ) );
}
public function pushover_user_callback() {
diff --git a/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php b/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php
index ad5fa84..c526113 100644
--- a/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php
+++ b/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php
@@ -102,9 +102,9 @@ class PostmanDiagnosticTestController {
printf( '<h4>%s</h4>', __( 'Are you having issues with Postman?', Postman::TEXT_DOMAIN ) );
/* translators: where %1$s and %2$s are the URLs to the Troubleshooting and Support Forums on WordPress.org */
- printf( '<p style="margin:0 10px">%s</p>', sprintf( __( 'Please check the <a href="%1$s">troubleshooting and error messages</a> page and the <a href="%2$s">support forum</a>.', Postman::TEXT_DOMAIN ), 'https://wordpress.org/plugins/post-smtp/other_notes/', 'https://wordpress.org/support/plugin/postman-smtp' ) );
+ printf( '<p style="margin:0 10px">%s</p>', sprintf( __( 'Please check the <a href="%1$s">troubleshooting and error messages</a> page and the <a href="%2$s">support forum</a>.', Postman::TEXT_DOMAIN ), 'https://wordpress.org/plugins/post-smtp/other_notes/', 'https://wordpress.org/support/plugin/post-smtp' ) );
printf( '<h4>%s</h4>', __( 'Diagnostic Test', Postman::TEXT_DOMAIN ) );
- printf( '<p style="margin:0 10px">%s</p><br/>', sprintf( __( 'If you write for help, please include the following:', Postman::TEXT_DOMAIN ), 'https://wordpress.org/plugins/post-smtp/other_notes/', 'https://wordpress.org/support/plugin/postman-smtp' ) );
+ printf( '<p style="margin:0 10px">%s</p><br/>', sprintf( __( 'If you write for help, please include the following:', Postman::TEXT_DOMAIN ), 'https://wordpress.org/plugins/post-smtp/other_notes/', 'https://wordpress.org/support/plugin/post-smtp' ) );
printf( '<textarea readonly="readonly" id="diagnostic-text" cols="80" rows="15">%s</textarea>', _x( 'Checking..', 'The "please wait" message', Postman::TEXT_DOMAIN ) );
print '</div>';
}
diff --git a/Postman/Postman-Email-Log/PostmanEmailLogController.php b/Postman/Postman-Email-Log/PostmanEmailLogController.php
index d1f0057..be08232 100644
--- a/Postman/Postman-Email-Log/PostmanEmailLogController.php
+++ b/Postman/Postman-Email-Log/PostmanEmailLogController.php
@@ -302,7 +302,7 @@ class PostmanEmailLogController {
$pageTitle = sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) );
$pluginName = _x( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN );
- $page = add_submenu_page( PostmanViewController::POSTMAN_MENU_SLUG, $pageTitle, $pluginName, 'read_private_posts', 'postman_email_log', array( $this, 'postman_render_email_page' ) );
+ $page = add_submenu_page( PostmanViewController::POSTMAN_MENU_SLUG, $pageTitle, $pluginName, Postman::MANAGE_POSTMAN_CAPABILITY_LOGS, 'postman_email_log', array( $this, 'postman_render_email_page' ) );
// When the plugin options page is loaded, also load the stylesheet
add_action( 'admin_print_styles-' . $page, array(
diff --git a/Postman/Postman-Email-Log/PostmanEmailLogService.php b/Postman/Postman-Email-Log/PostmanEmailLogService.php
index 103dcc1..dd51974 100644
--- a/Postman/Postman-Email-Log/PostmanEmailLogService.php
+++ b/Postman/Postman-Email-Log/PostmanEmailLogService.php
@@ -16,6 +16,10 @@ if ( ! class_exists( 'PostmanEmailLog' ) ) {
public $originalSubject;
public $originalMessage;
public $originalHeaders;
+
+ public function setStatusMessage( $message ) {
+ $this->statusMessage .= $message;
+ }
}
}
@@ -95,7 +99,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
public function writeFailureLog( PostmanEmailLog $log, PostmanMessage $message = null, $transcript, PostmanModuleTransport $transport, $statusMessage ) {
if ( PostmanOptions::getInstance()->isMailLoggingEnabled() ) {
$this->createLog( $log, $message, $transcript, $statusMessage, false, $transport );
- $this->writeToEmailLog( $log );
+ $this->writeToEmailLog( $log,$message );
}
}
@@ -104,21 +108,43 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
*
* From http://wordpress.stackexchange.com/questions/8569/wp-insert-post-php-function-and-custom-fields
*/
- private function writeToEmailLog( PostmanEmailLog $log ) {
+ private function writeToEmailLog( PostmanEmailLog $log, PostmanMessage $message = null ) {
+
+ $options = PostmanOptions::getInstance();
+
+ $this->checkForLogErrors( $log ,$message );
+ $new_status = $log->statusMessage;
+
+ if ( $options->is_fallback && empty( $log->statusMessage ) ) {
+ $new_status = 'Sent ( ** Fallback ** )';
+ }
+
+ if ( $options->is_fallback && ! empty( $log->statusMessage ) ) {
+ $new_status = '( ** Fallback ** ) ' . $log->statusMessage;
+ }
- $this->checkForLogErrors( $log );
// nothing here is sanitized as WordPress should take care of
// making database writes safe
$my_post = array(
'post_type' => PostmanEmailLogPostType::POSTMAN_CUSTOM_POST_TYPE_SLUG,
'post_title' => $log->subject,
'post_content' => $log->body,
- 'post_excerpt' => $log->statusMessage,
+ 'post_excerpt' => $new_status,
'post_status' => PostmanEmailLogService::POSTMAN_CUSTOM_POST_STATUS_PRIVATE,
);
// Insert the post into the database (WordPress gives us the Post ID)
- $post_id = wp_insert_post( $my_post );
+ $post_id = wp_insert_post( $my_post, true );
+
+ if ( is_wp_error( $post_id ) ) {
+ add_action( 'admin_notices', function() use( $post_id ) {
+ $class = 'notice notice-error';
+ $message = $post_id->get_error_message();
+
+ printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) );
+ });
+ }
+
$this->logger->debug( sprintf( 'Saved message #%s to the database', $post_id ) );
$this->logger->trace( $log );
@@ -155,7 +181,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
$purger->truncateLogItems( PostmanOptions::getInstance()->getMailLoggingMaxEntries() );
}
- private function checkForLogErrors( PostmanEmailLog $log ) {
+ private function checkForLogErrors( PostmanEmailLog $log, $postMessage ) {
$message = __( 'You getting this message because an error detected while delivered your email.', Postman::TEXT_DOMAIN );
$message .= "\r\n" . sprintf( __( 'For the domain: %1$s',Postman::TEXT_DOMAIN ), get_bloginfo('url') );
$message .= "\r\n" . __( 'The log to paste when you open a support issue:', Postman::TEXT_DOMAIN ) . "\r\n";
@@ -180,7 +206,8 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
$notifyer = new PostmanMailNotify;
}
- $notify = new PostmanNotify( $notifyer, $message );
+ // Notifications
+ $notify = new PostmanNotify( $notifyer );
$notify->send($message, $log);
$notify->push_to_chrome($log->statusMessage);
}
diff --git a/Postman/Postman-Mail/PostmanMyMailConnector.php b/Postman/Postman-Mail/PostmanMyMailConnector.php
index 151deed..e08aa02 100644
--- a/Postman/Postman-Mail/PostmanMyMailConnector.php
+++ b/Postman/Postman-Mail/PostmanMyMailConnector.php
@@ -1,6 +1,6 @@
<?php
-define( 'MYMAIL_POSTMAN_REQUIRED_VERSION', '2.0' );
-define( 'MYMAIL_POSTMAN_ID', 'postman' );
+define( 'MAILSTER_POSTMAN_REQUIRED_VERSION', '2.0' );
+define( 'MAILSTER_POSTMAN_ID', 'postman' );
/**
* Enables MyMail to deliver via Postman
@@ -36,36 +36,36 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
* Initialize the Connector
*/
public function init() {
- if ( ! defined( 'MYMAIL_VERSION' ) || version_compare( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '>' ) ) {
+ if ( ! defined( 'MAILSTER_VERSION' ) || version_compare( MAILSTER_POSTMAN_REQUIRED_VERSION, MAILSTER_VERSION, '>' ) ) {
// no-op
} else {
// create an instance of the Logger
$this->logger = new PostmanLogger( get_class( $this ) );
$this->logger->debug( 'Starting' );
- add_filter( 'mymail_delivery_methods', array(
+ add_filter( 'mailster_delivery_methods', array(
&$this,
'delivery_method',
) );
- add_action( 'mymail_deliverymethod_tab_postman', array(
+ add_action( 'mailster_deliverymethod_tab_postman', array(
&$this,
'deliverytab',
) );
- if ( mymail_option( 'deliverymethod' ) == MYMAIL_POSTMAN_ID ) {
- add_action( 'mymail_initsend', array(
+ if ( mailster_option( 'deliverymethod' ) == MAILSTER_POSTMAN_ID ) {
+ add_action( 'mailster_initsend', array(
&$this,
'initsend',
) );
- add_action( 'mymail_presend', array(
+ add_action( 'mailster_presend', array(
&$this,
'presend',
) );
- add_action( 'mymail_dosend', array(
+ add_action( 'mailster_dosend', array(
&$this,
'dosend',
) );
- add_action( 'MYMAIL_POSTMAN_cron', array(
+ add_action( 'MAILSTER_POSTMAN_cron', array(
&$this,
'reset',
) );
@@ -76,7 +76,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
/**
* initsend function.
*
- * uses mymail_initsend hook to set initial settings
+ * uses mailster_initsend hook to set initial settings
*
* @access public
* @param mixed $mailobject
@@ -91,7 +91,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
/**
* presend function.
*
- * uses the mymail_presend hook to apply setttings before each mail
+ * uses the mailster_presend hook to apply setttings before each mail
*
* @access public
* @param mixed $mailobject
@@ -110,7 +110,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
/**
* dosend function.
*
- * uses the mymail_dosend hook and triggers the send
+ * uses the mailster_dosend hook and triggers the send
*
* @access public
* @param mixed $mailobject
@@ -158,8 +158,8 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
* @return array
*/
public function reset() {
- update_option( '_transient__mymail_send_period_timeout', false );
- update_option( '_transient__mymail_send_period', 0 );
+ update_option( '_transient__mailster_send_period_timeout', false );
+ update_option( '_transient__mailster_send_period', 0 );
}
/**
@@ -172,7 +172,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
* @return void
*/
public function delivery_method( $delivery_methods ) {
- $delivery_methods [ MYMAIL_POSTMAN_ID ] = __( 'Postman SMTP', Postman::TEXT_DOMAIN );
+ $delivery_methods [ MAILSTER_POSTMAN_ID ] = __( 'Postman SMTP', Postman::TEXT_DOMAIN );
return $delivery_methods;
}
@@ -195,8 +195,8 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
* @return void
*/
public function activate() {
- if ( defined( 'MYMAIL_VERSION' ) && version_compare( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '<=' ) ) {
- mymail_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf( '<a href="options-general.php?page=newsletter-settings&mymail_remove_notice=mymail_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' );
+ if ( defined( 'MAILSTER_VERSION' ) && version_compare( MAILSTER_POSTMAN_REQUIRED_VERSION, MAILSTER_VERSION, '<=' ) ) {
+ mailster_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf( '<a href="edit.php?post_type=newsletter&page=mailster_settings&mailster_remove_notice=mailster_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' );
$this->reset();
}
}
@@ -208,11 +208,11 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
* @return void
*/
public function deactivate() {
- if ( defined( 'MYMAIL_VERSION' ) && function_exists( 'mymail_option' ) && version_compare( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '<=' ) ) {
- if ( mymail_option( 'deliverymethod' ) == MYMAIL_POSTMAN_ID ) {
- mymail_update_option( 'deliverymethod', 'simple' );
+ if ( defined( 'MAILSTER_VERSION' ) && function_exists( 'mailster_option' ) && version_compare( MAILSTER_POSTMAN_REQUIRED_VERSION, MAILSTER_VERSION, '<=' ) ) {
+ if ( mailster_option( 'deliverymethod' ) == MAILSTER_POSTMAN_ID ) {
+ mailster_update_option( 'deliverymethod', 'simple' );
/* Translators where %s is the name of the page */
- mymail_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf( '<a href="options-general.php?page=newsletter-settings&mymail_remove_notice=mymail_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' );
+ mailster_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf( '<a href="edit.php?post_type=newsletter&page=mailster_settings&mailster_remove_notice=mailster_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' );
}
}
}
diff --git a/Postman/Postman-Mail/PostmanSendGridMailEngine.php b/Postman/Postman-Mail/PostmanSendGridMailEngine.php
index 06302b0..32cfb9e 100644
--- a/Postman/Postman-Mail/PostmanSendGridMailEngine.php
+++ b/Postman/Postman-Mail/PostmanSendGridMailEngine.php
@@ -210,6 +210,7 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
$this->transcript .= print_r( $mail, true );
$this->logger->debug( 'Transcript=' . $this->transcript );
+
throw $e;
}
}
diff --git a/Postman/Postman-Mail/mailchimp-mandrill-api-php-da3adc10042e/src/Mandrill.php b/Postman/Postman-Mail/mailchimp-mandrill-api-php-da3adc10042e/src/Mandrill.php
index 61ebdca..4d4e675 100644
--- a/Postman/Postman-Mail/mailchimp-mandrill-api-php-da3adc10042e/src/Mandrill.php
+++ b/Postman/Postman-Mail/mailchimp-mandrill-api-php-da3adc10042e/src/Mandrill.php
@@ -149,7 +149,7 @@ class Postman_Mandrill {
public function castError($result) {
if($result['status'] !== 'error' || !$result['name']) throw new Postman_Mandrill_Error('We received an unexpected error: ' . json_encode($result));
- $class = (isset(self::$error_map[$result['name']])) ? self::$error_map[$result['name']] : 'Mandrill_Error';
+ $class = (isset(self::$error_map[$result['name']])) ? self::$error_map[$result['name']] : 'Postman_Mandrill_Error';
return new $class($result['message'], $result['code']);
}
diff --git a/Postman/Postman.php b/Postman/Postman.php
index ad86b57..b0f70e0 100644
--- a/Postman/Postman.php
+++ b/Postman/Postman.php
@@ -18,6 +18,7 @@ class Postman {
const ADMINISTRATOR_ROLE_NAME = 'administrator';
const MANAGE_POSTMAN_CAPABILITY_NAME = 'manage_postman_smtp';
+ const MANAGE_POSTMAN_CAPABILITY_LOGS = 'manage_postman_logs';
const TEXT_DOMAIN = 'post-smtp';
private $logger;
diff --git a/Postman/PostmanAdminController.php b/Postman/PostmanAdminController.php
index 03a7109..f85e30c 100644
--- a/Postman/PostmanAdminController.php
+++ b/Postman/PostmanAdminController.php
@@ -136,6 +136,17 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
'on_init',
) );
+ // continue to initialize the AdminController
+ add_action( 'wpmu_options', array(
+ $this,
+ 'wpmu_options',
+ ) );
+
+ add_action( 'update_wpmu_options', array(
+ $this,
+ 'update_wpmu_options',
+ ) );
+
// Adds "Settings" link to the plugin action page
add_filter( 'plugin_action_links_' . plugin_basename( $this->rootPluginFilenameAndPath ), array(
$this,
@@ -145,6 +156,68 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
require_once( 'PostmanPluginFeedback.php' );
}
+
+ function wpmu_options() {
+ $options = get_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS );
+ ?>
+ <input type="hidden" name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_global_settings]" value="null">
+ <input type="hidden" name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_allow_overwrite]" value="null">
+ <h2><?php _e( 'Post SMTP Settings', Postman::TEXT_DOMAIN ); ?></h2>
+ <table id="menu" class="form-table">
+ <tr>
+ <th scope="row">
+ <?php _e( 'Enable global settings', Postman::TEXT_DOMAIN ); ?>
+ </th>
+ <td>
+ <?php $checked = checked( $options['post_smtp_global_settings'], 1, false ); ?>
+ <label for="post-smtp-global-settings">
+ <input id="post-smtp-global-settings" type="checkbox"
+ name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_global_settings]"
+ value="1"
+ <?php echo $checked; ?>
+ >
+ <p class="description">
+ <?php _e('Same settings as the main site/blog (id:1)', Postman::TEXT_DOMAIN ); ?>
+ </p>
+ </label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row">
+ <?php _e( 'Allow user to load saved options', Postman::TEXT_DOMAIN ); ?>
+ </th>
+ <td>
+ <?php $checked = checked( $options['post_smtp_allow_overwrite'], 1, false ); ?>
+ <label for="post-smtp-allow-overwrite">
+ <input id="post-smtp-allow-overwrite" type="checkbox"
+ name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_allow_overwrite]"
+ value="1"
+ <?php echo $checked; ?>
+ >
+ </label>
+ </td>
+ </tr>
+ </table>
+ <?php
+ }
+
+ function update_wpmu_options() {
+ $options = get_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS );
+ if ( isset( $_POST[ PostmanOptions::POSTMAN_NETWORK_OPTIONS ] ) ) {
+ foreach ( $_POST[ PostmanOptions::POSTMAN_NETWORK_OPTIONS ] as $key => $value ) {
+ $options[$key] = sanitize_text_field( $value );
+
+ if ( $value == 'null' ) {
+ unset( $options[$key] );
+ }
+ }
+
+ update_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS, $options );
+ } else {
+ update_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS, array() );
+ }
+ }
+
/**
* Functions to execute on the init event
*
diff --git a/Postman/PostmanInputSanitizer.php b/Postman/PostmanInputSanitizer.php
index 9e1fa52..d2b01ae 100644
--- a/Postman/PostmanInputSanitizer.php
+++ b/Postman/PostmanInputSanitizer.php
@@ -69,14 +69,25 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) {
$this->sanitizeInt( 'Transcript Size', PostmanOptions::TRANSCRIPT_SIZE, $input, $new_input );
$this->sanitizeString( 'Temporary Directory', PostmanOptions::TEMPORARY_DIRECTORY, $input, $new_input );
+ // Notifications
$this->sanitizeString( 'Pushover Service', PostmanOptions::NOTIFICATION_SERVICE, $input, $new_input, $this->options->getNotificationService() );
$this->sanitizePassword( 'Pushover Username', PostmanOptions::PUSHOVER_USER, $input, $new_input, $this->options->getPushoverUser() );
$this->sanitizePassword( 'Pushover Token', PostmanOptions::PUSHOVER_TOKEN, $input, $new_input, $this->options->getPushoverToken() );
$this->sanitizePassword( 'Slack Token', PostmanOptions::SLACK_TOKEN, $input, $new_input, $this->options->getSlackToken() );
+ // Chrome extension
$this->sanitizeString( 'Push Chrome Extension', PostmanOptions::NOTIFICATION_USE_CHROME, $input, $new_input );
$this->sanitizePassword( 'Push Chrome Extension UID', PostmanOptions::NOTIFICATION_CHROME_UID, $input, $new_input, $this->options->getNotificationChromeUid() );
+ // Fallback
+ $this->sanitizeString( 'Use fallback', PostmanOptions::FALLBACK_SMTP_ENABLED, $input, $new_input );
+ $this->sanitizeString( 'Fallback hostname', PostmanOptions::FALLBACK_SMTP_HOSTNAME, $input, $new_input );
+ $this->sanitizeInt( 'Fallback port', PostmanOptions::FALLBACK_SMTP_PORT, $input, $new_input );
+ $this->sanitizeString( 'Fallback security', PostmanOptions::FALLBACK_SMTP_SECURITY, $input, $new_input );
+ $this->sanitizeString( 'Fallback auth', PostmanOptions::FALLBACK_SMTP_USE_AUTH, $input, $new_input );
+ $this->sanitizeString( 'Fallback username', PostmanOptions::FALLBACK_SMTP_USERNAME, $input, $new_input );
+ $this->sanitizePassword( 'Fallback password', PostmanOptions::FALLBACK_SMTP_PASSWORD, $input, $new_input, $this->options->getFallbackPassword() );
+
if ( $new_input [ PostmanOptions::CLIENT_ID ] != $this->options->getClientId() || $new_input [ PostmanOptions::CLIENT_SECRET ] != $this->options->getClientSecret() || $new_input [ PostmanOptions::HOSTNAME ] != $this->options->getHostname() ) {
$this->logger->debug( 'Recognized new Client ID' );
// the user entered a new client id and we should destroy the stored auth token
diff --git a/Postman/PostmanInstaller.php b/Postman/PostmanInstaller.php
index 4b2603b..f011251 100644
--- a/Postman/PostmanInstaller.php
+++ b/Postman/PostmanInstaller.php
@@ -12,6 +12,8 @@ require_once( 'PostmanOptions.php' );
class PostmanInstaller {
private $logger;
+ private $roles;
+
/**
*/
public function __construct() {
@@ -22,16 +24,39 @@ class PostmanInstaller {
* Handle activation of the plugin
*/
public function activatePostman() {
+ $options = get_option( PostmanOptions::POSTMAN_OPTIONS );
+ $args = array(
+ 'fallback_smtp_enabled' => 'no',
+ );
+
+ if ( empty( $options ) ) {
+ add_option( 'postman_options', $args );
+
+ } else {
+ if ( empty( $options['fallback_smtp_enabled'] ) ) {
+ $result = array_merge($options, $args);
+ update_option( PostmanOptions::POSTMAN_OPTIONS, $result );
+ }
+ }
+
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
+
+/* $role = get_role( Postman::ADMINISTRATOR_ROLE_NAME );
+ $role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME );
+ $role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_LOGS );*/
+
+ $options['post_smtp_allow_overwrite'] = '1';
+ update_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS, $options );
+
// handle network activation
// from https://wordpress.org/support/topic/new-function-wp_get_sites?replies=11
// run the activation function for each blog id
$old_blog = get_current_blog_id();
// Get all blog ids
- $subsites = wp_get_sites();
+ $subsites = get_sites();
foreach ( $subsites as $subsite ) {
- $this->logger->trace( 'multisite: switching to blog ' . $subsite ['blog_id'] );
- switch_to_blog( $subsite ['blog_id'] );
+ $this->logger->trace( 'multisite: switching to blog ' . $subsite->blog_id );
+ switch_to_blog( $subsite->blog_id );
$this->handleOptionUpdates();
$this->addCapability();
}
@@ -65,10 +90,10 @@ class PostmanInstaller {
// run the deactivation function for each blog id
$old_blog = get_current_blog_id();
// Get all blog ids
- $subsites = wp_get_sites();
+ $subsites = get_sites();
foreach ( $subsites as $subsite ) {
- $this->logger->trace( 'multisite: switching to blog ' . $subsite ['blog_id'] );
- switch_to_blog( $subsite ['blog_id'] );
+ $this->logger->trace( 'multisite: switching to blog ' . $subsite->blog_id );
+ switch_to_blog( $subsite->blog_id );
$this->removeCapability();
}
switch_to_blog( $old_blog );
@@ -90,6 +115,7 @@ class PostmanInstaller {
// add the custom capability to the administrator role
$role = get_role( Postman::ADMINISTRATOR_ROLE_NAME );
$role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME );
+ $role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_LOGS );
}
/**
@@ -104,6 +130,7 @@ class PostmanInstaller {
// remove the custom capability from the administrator role
$role = get_role( Postman::ADMINISTRATOR_ROLE_NAME );
$role->remove_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME );
+ $role->remove_cap( Postman::MANAGE_POSTMAN_CAPABILITY_LOGS );
}
/**
diff --git a/Postman/PostmanOptions.php b/Postman/PostmanOptions.php
index 29ddbc6..971cdd2 100644
--- a/Postman/PostmanOptions.php
+++ b/Postman/PostmanOptions.php
@@ -54,6 +54,7 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
// the option database name
const POSTMAN_OPTIONS = 'postman_options';
+ const POSTMAN_NETWORK_OPTIONS = 'postman_network_options';
// the options fields
const VERSION = 'version';
@@ -112,6 +113,15 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
const PUSHOVER_TOKEN = 'pushover_token';
const SLACK_TOKEN = 'slack_token';
+ // Fallback
+ const FALLBACK_SMTP_ENABLED = 'fallback_smtp_enabled';
+ const FALLBACK_SMTP_HOSTNAME = 'fallback_smtp_hostname';
+ const FALLBACK_SMTP_PORT = 'fallback_smtp_port';
+ const FALLBACK_SMTP_SECURITY = 'fallback_smtp_security';
+ const FALLBACK_SMTP_USE_AUTH = 'fallback_smtp_use_auth';
+ const FALLBACK_SMTP_USERNAME = 'fallback_smtp_username';
+ const FALLBACK_SMTP_PASSWORD = 'fallback_smtp_password';
+
// defaults
const DEFAULT_TRANSCRIPT_SIZE = 128;
const DEFAULT_STEALTH_MODE = false;
@@ -127,6 +137,8 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
const DEFAULT_PLUGIN_MESSAGE_SENDER_EMAIL_ENFORCED = false;
const DEFAULT_TEMP_DIRECTORY = '/tmp';
+ public $is_fallback = false;
+
// options data
private $options;
@@ -145,15 +157,36 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
private function __construct() {
$this->load();
}
+
public function save() {
- update_option( PostmanOptions::POSTMAN_OPTIONS, $this->options );
+ update_option( PostmanOptions::POSTMAN_OPTIONS, $this->options );
}
+
public function reload() {
$this->load();
}
+
private function load() {
- $this->options = get_option( PostmanOptions::POSTMAN_OPTIONS );
+
+ $options = get_option( self::POSTMAN_OPTIONS );
+
+ if ( is_multisite() ) {
+ $network_options = get_site_option( self::POSTMAN_NETWORK_OPTIONS );
+
+ if ( isset( $network_options['post_smtp_global_settings'] ) ) {
+ $blog_id = apply_filters( 'post_smtp_default_site_option', 1 );
+ } elseif ( $options && isset( $network_options['post_smtp_allow_overwrite'] ) ) {
+ $blog_id = get_current_blog_id();
+ }
+
+ switch_to_blog($blog_id);
+ $options = get_option( self::POSTMAN_OPTIONS );
+ restore_current_blog();
+ }
+
+ $this->options = $options;
}
+
public function isNew() {
return ! isset( $this->options [ PostmanOptions::TRANSPORT_TYPE ] );
}
@@ -231,18 +264,41 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
return $this->options [ self::ADDITIONAL_HEADERS ]; }
}
public function getHostname() {
+
+ if ( $this->is_fallback ) {
+ return $this->getFallbackHostname();
+ }
+
if ( isset( $this->options [ PostmanOptions::HOSTNAME ] ) ) {
return $this->options [ PostmanOptions::HOSTNAME ]; }
}
+
public function getPort() {
+
+ if ( $this->is_fallback ) {
+ return $this->getFallbackPort();
+ }
+
if ( isset( $this->options [ PostmanOptions::PORT ] ) ) {
return $this->options [ PostmanOptions::PORT ]; }
}
+
public function getEnvelopeSender() {
+
+ if ( $this->is_fallback ) {
+ return $this->getFallbackUsername();
+ }
+
if ( isset( $this->options [ PostmanOptions::ENVELOPE_SENDER ] ) ) {
return $this->options [ PostmanOptions::ENVELOPE_SENDER ]; }
}
+
public function getMessageSenderEmail() {
+
+ if ( $this->is_fallback ) {
+ return $this->getFallbackUsername();
+ }
+
if ( isset( $this->options [ PostmanOptions::MESSAGE_SENDER_EMAIL ] ) ) {
return $this->options [ PostmanOptions::MESSAGE_SENDER_EMAIL ]; }
}
@@ -258,21 +314,45 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
if ( isset( $this->options [ PostmanOptions::CLIENT_SECRET ] ) ) {
return $this->options [ PostmanOptions::CLIENT_SECRET ]; }
}
+
public function getTransportType() {
+
+ if ( $this->is_fallback ) {
+ return 'smtp';
+ }
+
if ( isset( $this->options [ PostmanOptions::TRANSPORT_TYPE ] ) ) {
return $this->options [ PostmanOptions::TRANSPORT_TYPE ]; }
}
+
public function getAuthenticationType() {
+
+ if ( $this->is_fallback ) {
+ return $this->getFallbackAuth();
+ }
+
if ( isset( $this->options [ PostmanOptions::AUTHENTICATION_TYPE ] ) ) {
return $this->options [ PostmanOptions::AUTHENTICATION_TYPE ]; }
}
+
public function getEncryptionType() {
+
+ if ( $this->is_fallback ) {
+ return $this->getFallbackSecurity();
+ }
+
+
if ( isset( $this->options [ PostmanOptions::SECURITY_TYPE ] ) ) {
return $this->options [ PostmanOptions::SECURITY_TYPE ];
}
}
public function getUsername() {
+
+ if ( $this->is_fallback ) {
+ return $this->getFallbackUsername();
+ }
+
if ( defined( 'POST_SMTP_AUTH_USERNAME' ) ) {
return POST_SMTP_AUTH_USERNAME;
}
@@ -281,15 +361,77 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
return $this->options [ PostmanOptions::BASIC_AUTH_USERNAME ];
}
}
- public function getPassword() {
- if ( defined( 'POST_SMTP_AUTH_PASSWORD' ) ) {
- return POST_SMTP_AUTH_PASSWORD;
- }
- if ( isset( $this->options [ PostmanOptions::BASIC_AUTH_PASSWORD ] ) ) {
- return base64_decode( $this->options [ PostmanOptions::BASIC_AUTH_PASSWORD ] );
- }
- }
+ public function getPassword() {
+
+ if ( $this->is_fallback ) {
+ return $this->getFallbackPassword();
+ }
+
+ if ( defined( 'POST_SMTP_AUTH_PASSWORD' ) ) {
+ return POST_SMTP_AUTH_PASSWORD;
+ }
+
+ if ( isset( $this->options [ PostmanOptions::BASIC_AUTH_PASSWORD ] ) ) {
+ return base64_decode( $this->options [ PostmanOptions::BASIC_AUTH_PASSWORD ] );
+ }
+ }
+
+ // Fallback
+ public function getFallbackIsEnabled() {
+ if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_ENABLED ] ) ) {
+ return $this->options [ PostmanOptions::FALLBACK_SMTP_ENABLED ];
+ }
+ return false;
+ }
+
+ public function getFallbackHostname() {
+ if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_HOSTNAME ] ) ) {
+ return $this->options [ PostmanOptions::FALLBACK_SMTP_HOSTNAME ];
+ }
+ }
+
+ public function getFallbackPort() {
+ if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_PORT ] ) ) {
+ return $this->options [ PostmanOptions::FALLBACK_SMTP_PORT ];
+ }
+ }
+
+ public function getFallbackSecurity() {
+ if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_SECURITY ] ) ) {
+ return $this->options [ PostmanOptions::FALLBACK_SMTP_SECURITY ];
+ }
+ }
+
+ public function getFallbackAuth() {
+ if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_USE_AUTH ] ) ) {
+ return $this->options [ PostmanOptions::FALLBACK_SMTP_USE_AUTH ];
+ }
+ }
+
+ public function getFallbackUsername() {
+ if ( defined( 'POST_SMTP_FALLBACK_AUTH_USERNAME' ) ) {
+ return POST_SMTP_FALLBACK_AUTH_USERNAME;
+ }
+
+ if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_USERNAME ] ) ) {
+ return $this->options [ PostmanOptions::FALLBACK_SMTP_USERNAME ];
+ }
+ }
+
+
+ public function getFallbackPassword() {
+ if ( defined( 'POST_SMTP_FALLBACK_AUTH_PASSWORD' ) ) {
+ return POST_SMTP_FALLBACK_AUTH_PASSWORD;
+ }
+
+ if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_PASSWORD ] ) ) {
+ return base64_decode( $this->options [ PostmanOptions::FALLBACK_SMTP_PASSWORD ] );
+ }
+ }
+
+ // End Fallback
+
public function getMandrillApiKey() {
if ( defined( 'POST_SMTP_API_KEY' ) ) {
return POST_SMTP_API_KEY;
@@ -376,10 +518,12 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
if ( isset( $this->options [ PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE ] ) ) {
return $this->options [ PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE ]; }
}
+
public function isEmailValidationDisabled() {
if ( isset( $this->options [ PostmanOptions::DISABLE_EMAIL_VALIDAITON ] ) ) {
return $this->options [ PostmanOptions::DISABLE_EMAIL_VALIDAITON ]; }
}
+
/**
* (non-PHPdoc)
*
diff --git a/Postman/PostmanUtils.php b/Postman/PostmanUtils.php
index 5405b79..8c7081f 100644
--- a/Postman/PostmanUtils.php
+++ b/Postman/PostmanUtils.php
@@ -36,6 +36,10 @@ class PostmanUtils {
* @return string
*/
public static function getPageUrl( $slug ) {
+ if ( is_network_admin() ) {
+ return network_admin_url( 'admin.php?page=' . $slug );
+ }
+
return get_admin_url() . 'admin.php?page=' . $slug;
}
@@ -393,6 +397,7 @@ class PostmanUtils {
if ( $logger->isTrace() ) {
$logger->trace( 'Registering admin menu ' . $callbackName );
}
+
add_action( 'admin_menu', array(
$viewController,
$callbackName,
diff --git a/Postman/PostmanViewController.php b/Postman/PostmanViewController.php
index c0025a9..6fef916 100644
--- a/Postman/PostmanViewController.php
+++ b/Postman/PostmanViewController.php
@@ -38,10 +38,12 @@ 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( 'admin_init', array( $this, 'do_activation_redirect' ) );
}
+
function dismiss_version_notify() {
check_ajax_referer( 'postsmtp', 'security' );
@@ -307,7 +309,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
echo '
<div class="updated settings-error notice is-dismissible">
<p>
- <strong>Version ' . $version . ' We have a new Chrome Extension:</strong> <a target="_blank" href="https://postmansmtp.com/post-smtp-1-9-6-new-chrome-extension/">Read Here</a>
+ <strong>Version ' . $version . ' The SMTP Fallback ( A backup delivery SMTP ):</strong> <a target="_blank" href="https://postmansmtp.com/post-smtp-1-9-7-the-smtp-fallback/">Read Here</a>
</p>
<button style="z-index: 100;" data-version="'. $version . '" data-security="' . wp_create_nonce('postsmtp') .'" type="button" class="notice-dismiss postman-release-message">
<span class="screen-reader-text">Dismiss this notice.</span>
diff --git a/Postman/PostmanWpMail.php b/Postman/PostmanWpMail.php
index f5fcf7f..173b35e 100644
--- a/Postman/PostmanWpMail.php
+++ b/Postman/PostmanWpMail.php
@@ -235,6 +235,13 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
PostmanEmailLogService::getInstance()->writeFailureLog( $log, $message, $engine->getTranscript(), $transport, $e->getMessage() );
}
+ // Fallback
+ if ( $this->fallback( $log, $message, $options ) ) {
+
+ return true;
+
+ }
+
$mail_error_data = array(
'to' => $message->getToRecipients(),
'subject' => $message->getSubject(),
@@ -248,9 +255,29 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
// return failure
return false;
+
}
}
+ private function fallback( $log, $postMessage,$options ) {
+
+ if ( ! $options->is_fallback && $options->getFallbackIsEnabled() && $options->getFallbackIsEnabled() == 'yes' ) {
+
+ $options->is_fallback = true;
+
+ $status = $this->sendMessage( $postMessage, $log );
+
+ $options->is_fallback = false;
+
+ return $status;
+
+ } else {
+ $options->is_fallback = false;
+ }
+
+ return false;
+ }
+
/**
* Clean up after sending the mail
*
diff --git a/postman-smtp.php b/postman-smtp.php
index ba25f72..d6a2ee3 100644
--- a/postman-smtp.php
+++ b/postman-smtp.php
@@ -3,14 +3,17 @@
* 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.6
- * Author: Jason Hendriks, Yehuda Hassine
+ * Version: 1.9.7
+ * Author: Yehuda Hassine
* Text Domain: post-smtp
* Author URI: https://postmansmtp.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
+/*
+ * Post SMTP (aka Postman SMTP) was originally developed by Jason Hendriks
+ */
// The Postman Mail API
//
// filter postman_test_email: before calling wp_mail, implement this filter and return true to disable the success/fail counters
@@ -28,8 +31,9 @@
// -- class autoloading
// -- Add dismiss option for "unconfigured message" .. for multisites
// -- customize sent-mail icon WordPress dashboard
-// -- multisite support for site-wide email configuration. allow network admin to choose whether subdomains may override with their own settings. subdomains may override with their own settings.
// -- multiple mailbox support
+
+
/**
* DO some check and Start Postman
*/
@@ -122,5 +126,5 @@ function post_start( $startingMemory ) {
*/
function post_setupPostman() {
require_once 'Postman/Postman.php';
- $kevinCostner = new Postman( __FILE__, '1.9.6' );
+ $kevinCostner = new Postman( __FILE__, '1.9.7' );
}
diff --git a/readme.txt b/readme.txt
index 72cadbd..442faa0 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,10 +1,10 @@
=== Post SMTP Mailer/Email Log ===
-Contributors: yehudah ,jasonhendriks
+Contributors: yehudah
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: 5.0.3
-Stable tag: 1.9.6
+Stable tag: 1.9.7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -12,8 +12,9 @@ Send, log and troubleshoot your Outgoing Email easily. Supports everything: SMTP
== Description ==
-= Version 1.9.6 released - We have a new Chrome extension =
-New Chrome extension and small updates. [Read the detailes here](https://postmansmtp.com/post-smtp-1-9-6-new-chrome-extension/)
+= Version 1.9.7 released - The SMTP Fallback =
+A fallback is a unique solution only exist on Post SMTP.
+You can configure a backup SMTP, so if your emails are failing your site will keep sending emails !!! [Read the detailes here](https://postmansmtp.com/post-smtp-1-9-7-the-smtp-fallback/)
= The Only SMTP plugin with chrome Notifications =
Get notified if your emails are failing inside your Chrome browser. [Download here](https://chrome.google.com/webstore/detail/post-smtp-notifications/npklmbkpbknkmbohdbpikeidiaekjoch?hl=en-US)
@@ -92,7 +93,7 @@ SendGrid has a free SMTP plan that you can use to send up to 100 emails per day.
= CREDITS =
-Post SMTP (aka Postman SMTP) plugin was originally created by Jason Hendriks. It is now owned and maintained by Yehuda Hassine.
+Post SMTP (aka Postman SMTP) plugin was originally created by Jason Hendriks.
== Installation ==
@@ -289,13 +290,20 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a
== Changelog ==
+= 1.9.7 - 2019-02-17
+* New: Fallback Feature - Configure a backup SMTP when emails are failing.
+* New: WordPress Multisite compability - with global settings.
+* New: Email Log capability - give other user cheking the logs.
+* Fixed: compatibility with mailster plugin
+* Fixed: Mandrill exception bug - Thanks to Niels de Blaauw from Level-Level
+
= 1.9.6 - 2019-01-29
* Added support for our new chrome notification extension.
* few fixes
= 1.9.5 - 2018-10-02
* Added support for Mailgun Europe region.
-* Replace "buggey" mime_content_type php function
+* Replace "buggy" mime_content_type php function
= 1.9.4 - 2018-08-03
The most stupid idea ever remove (auto security select)