Version Description
- 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
Download this release
Release Info
Developer | yehudah |
Plugin | Post SMTP Mailer/Email Log |
Version | 1.9.7 |
Comparing to | |
See all releases |
Code changes from version 1.9.6 to 1.9.7
- Postman/Postman-Configuration/PostmanConfigurationController.php +113 -0
- Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php +4 -2
- Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php +2 -2
- Postman/Postman-Email-Log/PostmanEmailLogController.php +1 -1
- Postman/Postman-Email-Log/PostmanEmailLogService.php +34 -7
- Postman/Postman-Mail/PostmanMyMailConnector.php +22 -22
- Postman/Postman-Mail/PostmanSendGridMailEngine.php +1 -0
- Postman/Postman-Mail/mailchimp-mandrill-api-php-da3adc10042e/src/Mandrill.php +1 -1
- Postman/Postman.php +1 -0
- Postman/PostmanAdminController.php +73 -0
- Postman/PostmanInputSanitizer.php +11 -0
- Postman/PostmanInstaller.php +33 -6
- Postman/PostmanOptions.php +159 -10
- Postman/PostmanUtils.php +5 -0
- Postman/PostmanViewController.php +3 -1
- Postman/PostmanWpMail.php +27 -0
- postman-smtp.php +8 -4
- readme.txt +14 -6
Postman/Postman-Configuration/PostmanConfigurationController.php
CHANGED
@@ -197,14 +197,18 @@ class PostmanConfigurationController {
|
|
197 |
PostmanViewController::outputChildPageHeader( __( 'Settings', Postman::TEXT_DOMAIN ), 'advanced_config' );
|
198 |
print '<div id="config_tabs"><ul>';
|
199 |
print sprintf( '<li><a href="#account_config">%s</a></li>', __( 'Account', Postman::TEXT_DOMAIN ) );
|
|
|
200 |
print sprintf( '<li><a href="#message_config">%s</a></li>', __( 'Message', Postman::TEXT_DOMAIN ) );
|
201 |
print sprintf( '<li><a href="#logging_config">%s</a></li>', __( 'Logging', Postman::TEXT_DOMAIN ) );
|
202 |
print sprintf( '<li><a href="#advanced_options_config">%s</a></li>', __( 'Advanced', Postman::TEXT_DOMAIN ) );
|
203 |
print sprintf( '<li><a href="#notifications">%s</a></li>', __( 'Notifications', Postman::TEXT_DOMAIN ) );
|
204 |
print '</ul>';
|
|
|
205 |
print '<form method="post" action="options.php">';
|
206 |
// This prints out all hidden setting fields
|
207 |
settings_fields( PostmanAdminController::SETTINGS_GROUP_NAME );
|
|
|
|
|
208 |
print '<section id="account_config">';
|
209 |
if ( sizeof( PostmanTransportRegistry::getInstance()->getTransports() ) > 1 ) {
|
210 |
do_settings_sections( 'transport_options' );
|
@@ -230,6 +234,115 @@ class PostmanConfigurationController {
|
|
230 |
do_settings_sections( PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS );
|
231 |
print '</div>';
|
232 |
print '</section>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
print '<section id="message_config">';
|
234 |
do_settings_sections( PostmanAdminController::MESSAGE_SENDER_OPTIONS );
|
235 |
do_settings_sections( PostmanAdminController::MESSAGE_FROM_OPTIONS );
|
197 |
PostmanViewController::outputChildPageHeader( __( 'Settings', Postman::TEXT_DOMAIN ), 'advanced_config' );
|
198 |
print '<div id="config_tabs"><ul>';
|
199 |
print sprintf( '<li><a href="#account_config">%s</a></li>', __( 'Account', Postman::TEXT_DOMAIN ) );
|
200 |
+
print sprintf( '<li><a href="#fallback">%s</a></li>', __( 'Fallback', Postman::TEXT_DOMAIN ) );
|
201 |
print sprintf( '<li><a href="#message_config">%s</a></li>', __( 'Message', Postman::TEXT_DOMAIN ) );
|
202 |
print sprintf( '<li><a href="#logging_config">%s</a></li>', __( 'Logging', Postman::TEXT_DOMAIN ) );
|
203 |
print sprintf( '<li><a href="#advanced_options_config">%s</a></li>', __( 'Advanced', Postman::TEXT_DOMAIN ) );
|
204 |
print sprintf( '<li><a href="#notifications">%s</a></li>', __( 'Notifications', Postman::TEXT_DOMAIN ) );
|
205 |
print '</ul>';
|
206 |
+
|
207 |
print '<form method="post" action="options.php">';
|
208 |
// This prints out all hidden setting fields
|
209 |
settings_fields( PostmanAdminController::SETTINGS_GROUP_NAME );
|
210 |
+
|
211 |
+
// account_config
|
212 |
print '<section id="account_config">';
|
213 |
if ( sizeof( PostmanTransportRegistry::getInstance()->getTransports() ) > 1 ) {
|
214 |
do_settings_sections( 'transport_options' );
|
234 |
do_settings_sections( PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS );
|
235 |
print '</div>';
|
236 |
print '</section>';
|
237 |
+
// end account config
|
238 |
+
?>
|
239 |
+
|
240 |
+
<!-- Fallback Start -->
|
241 |
+
<section id="fallback">
|
242 |
+
<h2><?php esc_html_e( 'Failed emails fallback', Postman::TEXT_DOMAIN ); ?></h2>
|
243 |
+
<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>
|
244 |
+
<table class="form-table">
|
245 |
+
<tr valign="">
|
246 |
+
<th scope="row"><?php _e( 'Use Fallback?', Postman::TEXT_DOMAIN ); ?></th>
|
247 |
+
<td>
|
248 |
+
<label>
|
249 |
+
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_ENABLED; ?>]" type="radio"
|
250 |
+
value="no"<?php echo checked( $this->options->getFallbackIsEnabled(), 'no' ); ?>>
|
251 |
+
<?php _e( 'No', Postman::TEXT_DOMAIN ); ?>
|
252 |
+
</label>
|
253 |
+
|
254 |
+
<label>
|
255 |
+
<?php $checked = checked( $this->options->getFallbackIsEnabled(), 'yes', false ); ?>
|
256 |
+
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_ENABLED; ?>]" type="radio"
|
257 |
+
value="yes"<?php echo checked( $this->options->getFallbackIsEnabled(), 'yes' ); ?>>
|
258 |
+
<?php _e( 'Yes', Postman::TEXT_DOMAIN ); ?>
|
259 |
+
</label>
|
260 |
+
</td>
|
261 |
+
</tr>
|
262 |
+
|
263 |
+
<tr>
|
264 |
+
<th scope="row"><?php _e('Outgoing Mail Server', Postman::TEXT_DOMAIN ); ?></th>
|
265 |
+
<?php $host = $this->options->getFallbackHostname(); ?>
|
266 |
+
<td>
|
267 |
+
<input type="text" id="fallback-smtp-host" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_HOSTNAME; ?>]"
|
268 |
+
value="<?php echo $host; ?>" placeholder="Example: smtp.host.com">
|
269 |
+
</td>
|
270 |
+
</tr>
|
271 |
+
|
272 |
+
<tr>
|
273 |
+
<th scope="row"><?php _e('Mail Server Port', Postman::TEXT_DOMAIN ); ?></th>
|
274 |
+
<?php $port = $this->options->getFallbackPort(); ?>
|
275 |
+
<td>
|
276 |
+
<input type="number" id="fallback-smtp-port" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_PORT; ?>]"
|
277 |
+
value="<?php echo $port; ?>" placeholder="Example: 587">
|
278 |
+
</td>
|
279 |
+
</tr>
|
280 |
+
|
281 |
+
<tr>
|
282 |
+
<th scope="row"><?php _e('Security', Postman::TEXT_DOMAIN ); ?></th>
|
283 |
+
<?php
|
284 |
+
$security_options = array(
|
285 |
+
'none' => __( 'None', Postman::TEXT_DOMAIN ),
|
286 |
+
'ssl' => __( 'SSL', Postman::TEXT_DOMAIN ),
|
287 |
+
'tls' => __( 'TLS', Postman::TEXT_DOMAIN ),
|
288 |
+
);
|
289 |
+
?>
|
290 |
+
<td>
|
291 |
+
<select id="fallback-smtp-security" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_SECURITY; ?>]">
|
292 |
+
<?php
|
293 |
+
foreach ( $security_options as $key => $label ) {
|
294 |
+
$selected = selected( $this->options->getFallbackSecurity(), $key,false );
|
295 |
+
?>
|
296 |
+
<option value="<?php echo $key; ?>"<?php echo $selected; ?>><?php echo $label; ?></option>
|
297 |
+
<?php
|
298 |
+
}
|
299 |
+
?>
|
300 |
+
</select>
|
301 |
+
</td>
|
302 |
+
</tr>
|
303 |
+
|
304 |
+
<tr valign="">
|
305 |
+
<th scope="row"><?php _e( 'Use SMTP Authentication?', Postman::TEXT_DOMAIN ); ?></th>
|
306 |
+
<td>
|
307 |
+
<label>
|
308 |
+
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USE_AUTH; ?>]"
|
309 |
+
type="radio" value="none"<?php checked( $this->options->getFallbackAuth(), 'none' ); ?>>
|
310 |
+
<?php _e( 'No', Postman::TEXT_DOMAIN ); ?>
|
311 |
+
</label>
|
312 |
+
|
313 |
+
<label>
|
314 |
+
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USE_AUTH; ?>]"
|
315 |
+
type="radio" value="login"<?php checked( $this->options->getFallbackAuth(), 'login' ); ?>>
|
316 |
+
<?php _e( 'Yes', Postman::TEXT_DOMAIN ); ?>
|
317 |
+
</label>
|
318 |
+
</td>
|
319 |
+
</tr>
|
320 |
+
|
321 |
+
<tr>
|
322 |
+
<th scope="row"><?php _e('User name', Postman::TEXT_DOMAIN ); ?></th>
|
323 |
+
<td>
|
324 |
+
<input type="text" id="fallback-smtp-username"
|
325 |
+
value="<?php echo $this->options->getFallbackUsername(); ?>"
|
326 |
+
name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USERNAME; ?>]"
|
327 |
+
>
|
328 |
+
</td>
|
329 |
+
</tr>
|
330 |
+
|
331 |
+
<tr>
|
332 |
+
<th scope="row"><?php _e('Password', Postman::TEXT_DOMAIN ); ?></th>
|
333 |
+
<td>
|
334 |
+
<input type="password" id="fallback-smtp-password"
|
335 |
+
value="<?php echo PostmanUtils::obfuscatePassword( $this->options->getFallbackPassword() ); ?>"
|
336 |
+
name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_PASSWORD; ?>]"
|
337 |
+
>
|
338 |
+
</td>
|
339 |
+
</tr>
|
340 |
+
|
341 |
+
</table>
|
342 |
+
</section>
|
343 |
+
<!-- Fallback End -->
|
344 |
+
|
345 |
+
<?php
|
346 |
print '<section id="message_config">';
|
347 |
do_settings_sections( PostmanAdminController::MESSAGE_SENDER_OPTIONS );
|
348 |
do_settings_sections( PostmanAdminController::MESSAGE_FROM_OPTIONS );
|
Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
CHANGED
@@ -21,7 +21,7 @@ class PostmanSettingsRegistry {
|
|
21 |
|
22 |
// only administrators should be able to trigger this
|
23 |
if ( PostmanUtils::isAdmin() ) {
|
24 |
-
|
25 |
register_setting( PostmanAdminController::SETTINGS_GROUP_NAME, PostmanOptions::POSTMAN_OPTIONS, array(
|
26 |
$sanitizer,
|
27 |
'sanitize',
|
@@ -101,6 +101,8 @@ class PostmanSettingsRegistry {
|
|
101 |
'headers_callback',
|
102 |
), PostmanAdminController::MESSAGE_HEADERS_OPTIONS, PostmanAdminController::MESSAGE_HEADERS_SECTION );
|
103 |
|
|
|
|
|
104 |
// the Email Validation section
|
105 |
add_settings_section( PostmanAdminController::EMAIL_VALIDATION_SECTION, __( 'Validation', Postman::TEXT_DOMAIN ), array(
|
106 |
$this,
|
@@ -431,7 +433,7 @@ class PostmanSettingsRegistry {
|
|
431 |
}
|
432 |
|
433 |
public function notification_chrome_uid_callback() {
|
434 |
-
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() );
|
435 |
}
|
436 |
|
437 |
public function pushover_user_callback() {
|
21 |
|
22 |
// only administrators should be able to trigger this
|
23 |
if ( PostmanUtils::isAdmin() ) {
|
24 |
+
$sanitizer = new PostmanInputSanitizer();
|
25 |
register_setting( PostmanAdminController::SETTINGS_GROUP_NAME, PostmanOptions::POSTMAN_OPTIONS, array(
|
26 |
$sanitizer,
|
27 |
'sanitize',
|
101 |
'headers_callback',
|
102 |
), PostmanAdminController::MESSAGE_HEADERS_OPTIONS, PostmanAdminController::MESSAGE_HEADERS_SECTION );
|
103 |
|
104 |
+
// Fallback
|
105 |
+
|
106 |
// the Email Validation section
|
107 |
add_settings_section( PostmanAdminController::EMAIL_VALIDATION_SECTION, __( 'Validation', Postman::TEXT_DOMAIN ), array(
|
108 |
$this,
|
433 |
}
|
434 |
|
435 |
public function notification_chrome_uid_callback() {
|
436 |
+
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() ) );
|
437 |
}
|
438 |
|
439 |
public function pushover_user_callback() {
|
Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php
CHANGED
@@ -102,9 +102,9 @@ class PostmanDiagnosticTestController {
|
|
102 |
|
103 |
printf( '<h4>%s</h4>', __( 'Are you having issues with Postman?', Postman::TEXT_DOMAIN ) );
|
104 |
/* translators: where %1$s and %2$s are the URLs to the Troubleshooting and Support Forums on WordPress.org */
|
105 |
-
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/
|
106 |
printf( '<h4>%s</h4>', __( 'Diagnostic Test', Postman::TEXT_DOMAIN ) );
|
107 |
-
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/
|
108 |
printf( '<textarea readonly="readonly" id="diagnostic-text" cols="80" rows="15">%s</textarea>', _x( 'Checking..', 'The "please wait" message', Postman::TEXT_DOMAIN ) );
|
109 |
print '</div>';
|
110 |
}
|
102 |
|
103 |
printf( '<h4>%s</h4>', __( 'Are you having issues with Postman?', Postman::TEXT_DOMAIN ) );
|
104 |
/* translators: where %1$s and %2$s are the URLs to the Troubleshooting and Support Forums on WordPress.org */
|
105 |
+
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' ) );
|
106 |
printf( '<h4>%s</h4>', __( 'Diagnostic Test', Postman::TEXT_DOMAIN ) );
|
107 |
+
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' ) );
|
108 |
printf( '<textarea readonly="readonly" id="diagnostic-text" cols="80" rows="15">%s</textarea>', _x( 'Checking..', 'The "please wait" message', Postman::TEXT_DOMAIN ) );
|
109 |
print '</div>';
|
110 |
}
|
Postman/Postman-Email-Log/PostmanEmailLogController.php
CHANGED
@@ -302,7 +302,7 @@ class PostmanEmailLogController {
|
|
302 |
$pageTitle = sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) );
|
303 |
$pluginName = _x( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN );
|
304 |
|
305 |
-
$page = add_submenu_page( PostmanViewController::POSTMAN_MENU_SLUG, $pageTitle, $pluginName,
|
306 |
|
307 |
// When the plugin options page is loaded, also load the stylesheet
|
308 |
add_action( 'admin_print_styles-' . $page, array(
|
302 |
$pageTitle = sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) );
|
303 |
$pluginName = _x( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN );
|
304 |
|
305 |
+
$page = add_submenu_page( PostmanViewController::POSTMAN_MENU_SLUG, $pageTitle, $pluginName, Postman::MANAGE_POSTMAN_CAPABILITY_LOGS, 'postman_email_log', array( $this, 'postman_render_email_page' ) );
|
306 |
|
307 |
// When the plugin options page is loaded, also load the stylesheet
|
308 |
add_action( 'admin_print_styles-' . $page, array(
|
Postman/Postman-Email-Log/PostmanEmailLogService.php
CHANGED
@@ -16,6 +16,10 @@ if ( ! class_exists( 'PostmanEmailLog' ) ) {
|
|
16 |
public $originalSubject;
|
17 |
public $originalMessage;
|
18 |
public $originalHeaders;
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
}
|
21 |
|
@@ -95,7 +99,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
|
|
95 |
public function writeFailureLog( PostmanEmailLog $log, PostmanMessage $message = null, $transcript, PostmanModuleTransport $transport, $statusMessage ) {
|
96 |
if ( PostmanOptions::getInstance()->isMailLoggingEnabled() ) {
|
97 |
$this->createLog( $log, $message, $transcript, $statusMessage, false, $transport );
|
98 |
-
$this->writeToEmailLog( $log );
|
99 |
}
|
100 |
}
|
101 |
|
@@ -104,21 +108,43 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
|
|
104 |
*
|
105 |
* From http://wordpress.stackexchange.com/questions/8569/wp-insert-post-php-function-and-custom-fields
|
106 |
*/
|
107 |
-
private function writeToEmailLog( PostmanEmailLog $log ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
-
$this->checkForLogErrors( $log );
|
110 |
// nothing here is sanitized as WordPress should take care of
|
111 |
// making database writes safe
|
112 |
$my_post = array(
|
113 |
'post_type' => PostmanEmailLogPostType::POSTMAN_CUSTOM_POST_TYPE_SLUG,
|
114 |
'post_title' => $log->subject,
|
115 |
'post_content' => $log->body,
|
116 |
-
'post_excerpt' => $
|
117 |
'post_status' => PostmanEmailLogService::POSTMAN_CUSTOM_POST_STATUS_PRIVATE,
|
118 |
);
|
119 |
|
120 |
// Insert the post into the database (WordPress gives us the Post ID)
|
121 |
-
$post_id = wp_insert_post( $my_post );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
$this->logger->debug( sprintf( 'Saved message #%s to the database', $post_id ) );
|
123 |
$this->logger->trace( $log );
|
124 |
|
@@ -155,7 +181,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
|
|
155 |
$purger->truncateLogItems( PostmanOptions::getInstance()->getMailLoggingMaxEntries() );
|
156 |
}
|
157 |
|
158 |
-
private function checkForLogErrors( PostmanEmailLog $log ) {
|
159 |
$message = __( 'You getting this message because an error detected while delivered your email.', Postman::TEXT_DOMAIN );
|
160 |
$message .= "\r\n" . sprintf( __( 'For the domain: %1$s',Postman::TEXT_DOMAIN ), get_bloginfo('url') );
|
161 |
$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' ) ) {
|
|
180 |
$notifyer = new PostmanMailNotify;
|
181 |
}
|
182 |
|
183 |
-
|
|
|
184 |
$notify->send($message, $log);
|
185 |
$notify->push_to_chrome($log->statusMessage);
|
186 |
}
|
16 |
public $originalSubject;
|
17 |
public $originalMessage;
|
18 |
public $originalHeaders;
|
19 |
+
|
20 |
+
public function setStatusMessage( $message ) {
|
21 |
+
$this->statusMessage .= $message;
|
22 |
+
}
|
23 |
}
|
24 |
}
|
25 |
|
99 |
public function writeFailureLog( PostmanEmailLog $log, PostmanMessage $message = null, $transcript, PostmanModuleTransport $transport, $statusMessage ) {
|
100 |
if ( PostmanOptions::getInstance()->isMailLoggingEnabled() ) {
|
101 |
$this->createLog( $log, $message, $transcript, $statusMessage, false, $transport );
|
102 |
+
$this->writeToEmailLog( $log,$message );
|
103 |
}
|
104 |
}
|
105 |
|
108 |
*
|
109 |
* From http://wordpress.stackexchange.com/questions/8569/wp-insert-post-php-function-and-custom-fields
|
110 |
*/
|
111 |
+
private function writeToEmailLog( PostmanEmailLog $log, PostmanMessage $message = null ) {
|
112 |
+
|
113 |
+
$options = PostmanOptions::getInstance();
|
114 |
+
|
115 |
+
$this->checkForLogErrors( $log ,$message );
|
116 |
+
$new_status = $log->statusMessage;
|
117 |
+
|
118 |
+
if ( $options->is_fallback && empty( $log->statusMessage ) ) {
|
119 |
+
$new_status = 'Sent ( ** Fallback ** )';
|
120 |
+
}
|
121 |
+
|
122 |
+
if ( $options->is_fallback && ! empty( $log->statusMessage ) ) {
|
123 |
+
$new_status = '( ** Fallback ** ) ' . $log->statusMessage;
|
124 |
+
}
|
125 |
|
|
|
126 |
// nothing here is sanitized as WordPress should take care of
|
127 |
// making database writes safe
|
128 |
$my_post = array(
|
129 |
'post_type' => PostmanEmailLogPostType::POSTMAN_CUSTOM_POST_TYPE_SLUG,
|
130 |
'post_title' => $log->subject,
|
131 |
'post_content' => $log->body,
|
132 |
+
'post_excerpt' => $new_status,
|
133 |
'post_status' => PostmanEmailLogService::POSTMAN_CUSTOM_POST_STATUS_PRIVATE,
|
134 |
);
|
135 |
|
136 |
// Insert the post into the database (WordPress gives us the Post ID)
|
137 |
+
$post_id = wp_insert_post( $my_post, true );
|
138 |
+
|
139 |
+
if ( is_wp_error( $post_id ) ) {
|
140 |
+
add_action( 'admin_notices', function() use( $post_id ) {
|
141 |
+
$class = 'notice notice-error';
|
142 |
+
$message = $post_id->get_error_message();
|
143 |
+
|
144 |
+
printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) );
|
145 |
+
});
|
146 |
+
}
|
147 |
+
|
148 |
$this->logger->debug( sprintf( 'Saved message #%s to the database', $post_id ) );
|
149 |
$this->logger->trace( $log );
|
150 |
|
181 |
$purger->truncateLogItems( PostmanOptions::getInstance()->getMailLoggingMaxEntries() );
|
182 |
}
|
183 |
|
184 |
+
private function checkForLogErrors( PostmanEmailLog $log, $postMessage ) {
|
185 |
$message = __( 'You getting this message because an error detected while delivered your email.', Postman::TEXT_DOMAIN );
|
186 |
$message .= "\r\n" . sprintf( __( 'For the domain: %1$s',Postman::TEXT_DOMAIN ), get_bloginfo('url') );
|
187 |
$message .= "\r\n" . __( 'The log to paste when you open a support issue:', Postman::TEXT_DOMAIN ) . "\r\n";
|
206 |
$notifyer = new PostmanMailNotify;
|
207 |
}
|
208 |
|
209 |
+
// Notifications
|
210 |
+
$notify = new PostmanNotify( $notifyer );
|
211 |
$notify->send($message, $log);
|
212 |
$notify->push_to_chrome($log->statusMessage);
|
213 |
}
|
Postman/Postman-Mail/PostmanMyMailConnector.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
-
define( '
|
3 |
-
define( '
|
4 |
|
5 |
/**
|
6 |
* Enables MyMail to deliver via Postman
|
@@ -36,36 +36,36 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
36 |
* Initialize the Connector
|
37 |
*/
|
38 |
public function init() {
|
39 |
-
if ( ! defined( '
|
40 |
// no-op
|
41 |
} else {
|
42 |
// create an instance of the Logger
|
43 |
$this->logger = new PostmanLogger( get_class( $this ) );
|
44 |
$this->logger->debug( 'Starting' );
|
45 |
|
46 |
-
add_filter( '
|
47 |
&$this,
|
48 |
'delivery_method',
|
49 |
) );
|
50 |
-
add_action( '
|
51 |
&$this,
|
52 |
'deliverytab',
|
53 |
) );
|
54 |
|
55 |
-
if (
|
56 |
-
add_action( '
|
57 |
&$this,
|
58 |
'initsend',
|
59 |
) );
|
60 |
-
add_action( '
|
61 |
&$this,
|
62 |
'presend',
|
63 |
) );
|
64 |
-
add_action( '
|
65 |
&$this,
|
66 |
'dosend',
|
67 |
) );
|
68 |
-
add_action( '
|
69 |
&$this,
|
70 |
'reset',
|
71 |
) );
|
@@ -76,7 +76,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
76 |
/**
|
77 |
* initsend function.
|
78 |
*
|
79 |
-
* uses
|
80 |
*
|
81 |
* @access public
|
82 |
* @param mixed $mailobject
|
@@ -91,7 +91,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
91 |
/**
|
92 |
* presend function.
|
93 |
*
|
94 |
-
* uses the
|
95 |
*
|
96 |
* @access public
|
97 |
* @param mixed $mailobject
|
@@ -110,7 +110,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
110 |
/**
|
111 |
* dosend function.
|
112 |
*
|
113 |
-
* uses the
|
114 |
*
|
115 |
* @access public
|
116 |
* @param mixed $mailobject
|
@@ -158,8 +158,8 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
158 |
* @return array
|
159 |
*/
|
160 |
public function reset() {
|
161 |
-
update_option( '
|
162 |
-
update_option( '
|
163 |
}
|
164 |
|
165 |
/**
|
@@ -172,7 +172,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
172 |
* @return void
|
173 |
*/
|
174 |
public function delivery_method( $delivery_methods ) {
|
175 |
-
$delivery_methods [
|
176 |
return $delivery_methods;
|
177 |
}
|
178 |
|
@@ -195,8 +195,8 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
195 |
* @return void
|
196 |
*/
|
197 |
public function activate() {
|
198 |
-
if ( defined( '
|
199 |
-
|
200 |
$this->reset();
|
201 |
}
|
202 |
}
|
@@ -208,11 +208,11 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
208 |
* @return void
|
209 |
*/
|
210 |
public function deactivate() {
|
211 |
-
if ( defined( '
|
212 |
-
if (
|
213 |
-
|
214 |
/* Translators where %s is the name of the page */
|
215 |
-
|
216 |
}
|
217 |
}
|
218 |
}
|
1 |
<?php
|
2 |
+
define( 'MAILSTER_POSTMAN_REQUIRED_VERSION', '2.0' );
|
3 |
+
define( 'MAILSTER_POSTMAN_ID', 'postman' );
|
4 |
|
5 |
/**
|
6 |
* Enables MyMail to deliver via Postman
|
36 |
* Initialize the Connector
|
37 |
*/
|
38 |
public function init() {
|
39 |
+
if ( ! defined( 'MAILSTER_VERSION' ) || version_compare( MAILSTER_POSTMAN_REQUIRED_VERSION, MAILSTER_VERSION, '>' ) ) {
|
40 |
// no-op
|
41 |
} else {
|
42 |
// create an instance of the Logger
|
43 |
$this->logger = new PostmanLogger( get_class( $this ) );
|
44 |
$this->logger->debug( 'Starting' );
|
45 |
|
46 |
+
add_filter( 'mailster_delivery_methods', array(
|
47 |
&$this,
|
48 |
'delivery_method',
|
49 |
) );
|
50 |
+
add_action( 'mailster_deliverymethod_tab_postman', array(
|
51 |
&$this,
|
52 |
'deliverytab',
|
53 |
) );
|
54 |
|
55 |
+
if ( mailster_option( 'deliverymethod' ) == MAILSTER_POSTMAN_ID ) {
|
56 |
+
add_action( 'mailster_initsend', array(
|
57 |
&$this,
|
58 |
'initsend',
|
59 |
) );
|
60 |
+
add_action( 'mailster_presend', array(
|
61 |
&$this,
|
62 |
'presend',
|
63 |
) );
|
64 |
+
add_action( 'mailster_dosend', array(
|
65 |
&$this,
|
66 |
'dosend',
|
67 |
) );
|
68 |
+
add_action( 'MAILSTER_POSTMAN_cron', array(
|
69 |
&$this,
|
70 |
'reset',
|
71 |
) );
|
76 |
/**
|
77 |
* initsend function.
|
78 |
*
|
79 |
+
* uses mailster_initsend hook to set initial settings
|
80 |
*
|
81 |
* @access public
|
82 |
* @param mixed $mailobject
|
91 |
/**
|
92 |
* presend function.
|
93 |
*
|
94 |
+
* uses the mailster_presend hook to apply setttings before each mail
|
95 |
*
|
96 |
* @access public
|
97 |
* @param mixed $mailobject
|
110 |
/**
|
111 |
* dosend function.
|
112 |
*
|
113 |
+
* uses the mailster_dosend hook and triggers the send
|
114 |
*
|
115 |
* @access public
|
116 |
* @param mixed $mailobject
|
158 |
* @return array
|
159 |
*/
|
160 |
public function reset() {
|
161 |
+
update_option( '_transient__mailster_send_period_timeout', false );
|
162 |
+
update_option( '_transient__mailster_send_period', 0 );
|
163 |
}
|
164 |
|
165 |
/**
|
172 |
* @return void
|
173 |
*/
|
174 |
public function delivery_method( $delivery_methods ) {
|
175 |
+
$delivery_methods [ MAILSTER_POSTMAN_ID ] = __( 'Postman SMTP', Postman::TEXT_DOMAIN );
|
176 |
return $delivery_methods;
|
177 |
}
|
178 |
|
195 |
* @return void
|
196 |
*/
|
197 |
public function activate() {
|
198 |
+
if ( defined( 'MAILSTER_VERSION' ) && version_compare( MAILSTER_POSTMAN_REQUIRED_VERSION, MAILSTER_VERSION, '<=' ) ) {
|
199 |
+
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' );
|
200 |
$this->reset();
|
201 |
}
|
202 |
}
|
208 |
* @return void
|
209 |
*/
|
210 |
public function deactivate() {
|
211 |
+
if ( defined( 'MAILSTER_VERSION' ) && function_exists( 'mailster_option' ) && version_compare( MAILSTER_POSTMAN_REQUIRED_VERSION, MAILSTER_VERSION, '<=' ) ) {
|
212 |
+
if ( mailster_option( 'deliverymethod' ) == MAILSTER_POSTMAN_ID ) {
|
213 |
+
mailster_update_option( 'deliverymethod', 'simple' );
|
214 |
/* Translators where %s is the name of the page */
|
215 |
+
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' );
|
216 |
}
|
217 |
}
|
218 |
}
|
Postman/Postman-Mail/PostmanSendGridMailEngine.php
CHANGED
@@ -210,6 +210,7 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
210 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
211 |
$this->transcript .= print_r( $mail, true );
|
212 |
$this->logger->debug( 'Transcript=' . $this->transcript );
|
|
|
213 |
throw $e;
|
214 |
}
|
215 |
}
|
210 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
211 |
$this->transcript .= print_r( $mail, true );
|
212 |
$this->logger->debug( 'Transcript=' . $this->transcript );
|
213 |
+
|
214 |
throw $e;
|
215 |
}
|
216 |
}
|
Postman/Postman-Mail/mailchimp-mandrill-api-php-da3adc10042e/src/Mandrill.php
CHANGED
@@ -149,7 +149,7 @@ class Postman_Mandrill {
|
|
149 |
public function castError($result) {
|
150 |
if($result['status'] !== 'error' || !$result['name']) throw new Postman_Mandrill_Error('We received an unexpected error: ' . json_encode($result));
|
151 |
|
152 |
-
$class = (isset(self::$error_map[$result['name']])) ? self::$error_map[$result['name']] : '
|
153 |
return new $class($result['message'], $result['code']);
|
154 |
}
|
155 |
|
149 |
public function castError($result) {
|
150 |
if($result['status'] !== 'error' || !$result['name']) throw new Postman_Mandrill_Error('We received an unexpected error: ' . json_encode($result));
|
151 |
|
152 |
+
$class = (isset(self::$error_map[$result['name']])) ? self::$error_map[$result['name']] : 'Postman_Mandrill_Error';
|
153 |
return new $class($result['message'], $result['code']);
|
154 |
}
|
155 |
|
Postman/Postman.php
CHANGED
@@ -18,6 +18,7 @@ class Postman {
|
|
18 |
|
19 |
const ADMINISTRATOR_ROLE_NAME = 'administrator';
|
20 |
const MANAGE_POSTMAN_CAPABILITY_NAME = 'manage_postman_smtp';
|
|
|
21 |
const TEXT_DOMAIN = 'post-smtp';
|
22 |
|
23 |
private $logger;
|
18 |
|
19 |
const ADMINISTRATOR_ROLE_NAME = 'administrator';
|
20 |
const MANAGE_POSTMAN_CAPABILITY_NAME = 'manage_postman_smtp';
|
21 |
+
const MANAGE_POSTMAN_CAPABILITY_LOGS = 'manage_postman_logs';
|
22 |
const TEXT_DOMAIN = 'post-smtp';
|
23 |
|
24 |
private $logger;
|
Postman/PostmanAdminController.php
CHANGED
@@ -136,6 +136,17 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
136 |
'on_init',
|
137 |
) );
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
// Adds "Settings" link to the plugin action page
|
140 |
add_filter( 'plugin_action_links_' . plugin_basename( $this->rootPluginFilenameAndPath ), array(
|
141 |
$this,
|
@@ -145,6 +156,68 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
145 |
require_once( 'PostmanPluginFeedback.php' );
|
146 |
}
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
/**
|
149 |
* Functions to execute on the init event
|
150 |
*
|
136 |
'on_init',
|
137 |
) );
|
138 |
|
139 |
+
// continue to initialize the AdminController
|
140 |
+
add_action( 'wpmu_options', array(
|
141 |
+
$this,
|
142 |
+
'wpmu_options',
|
143 |
+
) );
|
144 |
+
|
145 |
+
add_action( 'update_wpmu_options', array(
|
146 |
+
$this,
|
147 |
+
'update_wpmu_options',
|
148 |
+
) );
|
149 |
+
|
150 |
// Adds "Settings" link to the plugin action page
|
151 |
add_filter( 'plugin_action_links_' . plugin_basename( $this->rootPluginFilenameAndPath ), array(
|
152 |
$this,
|
156 |
require_once( 'PostmanPluginFeedback.php' );
|
157 |
}
|
158 |
|
159 |
+
|
160 |
+
function wpmu_options() {
|
161 |
+
$options = get_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS );
|
162 |
+
?>
|
163 |
+
<input type="hidden" name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_global_settings]" value="null">
|
164 |
+
<input type="hidden" name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_allow_overwrite]" value="null">
|
165 |
+
<h2><?php _e( 'Post SMTP Settings', Postman::TEXT_DOMAIN ); ?></h2>
|
166 |
+
<table id="menu" class="form-table">
|
167 |
+
<tr>
|
168 |
+
<th scope="row">
|
169 |
+
<?php _e( 'Enable global settings', Postman::TEXT_DOMAIN ); ?>
|
170 |
+
</th>
|
171 |
+
<td>
|
172 |
+
<?php $checked = checked( $options['post_smtp_global_settings'], 1, false ); ?>
|
173 |
+
<label for="post-smtp-global-settings">
|
174 |
+
<input id="post-smtp-global-settings" type="checkbox"
|
175 |
+
name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_global_settings]"
|
176 |
+
value="1"
|
177 |
+
<?php echo $checked; ?>
|
178 |
+
>
|
179 |
+
<p class="description">
|
180 |
+
<?php _e('Same settings as the main site/blog (id:1)', Postman::TEXT_DOMAIN ); ?>
|
181 |
+
</p>
|
182 |
+
</label>
|
183 |
+
</td>
|
184 |
+
</tr>
|
185 |
+
<tr>
|
186 |
+
<th scope="row">
|
187 |
+
<?php _e( 'Allow user to load saved options', Postman::TEXT_DOMAIN ); ?>
|
188 |
+
</th>
|
189 |
+
<td>
|
190 |
+
<?php $checked = checked( $options['post_smtp_allow_overwrite'], 1, false ); ?>
|
191 |
+
<label for="post-smtp-allow-overwrite">
|
192 |
+
<input id="post-smtp-allow-overwrite" type="checkbox"
|
193 |
+
name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_allow_overwrite]"
|
194 |
+
value="1"
|
195 |
+
<?php echo $checked; ?>
|
196 |
+
>
|
197 |
+
</label>
|
198 |
+
</td>
|
199 |
+
</tr>
|
200 |
+
</table>
|
201 |
+
<?php
|
202 |
+
}
|
203 |
+
|
204 |
+
function update_wpmu_options() {
|
205 |
+
$options = get_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS );
|
206 |
+
if ( isset( $_POST[ PostmanOptions::POSTMAN_NETWORK_OPTIONS ] ) ) {
|
207 |
+
foreach ( $_POST[ PostmanOptions::POSTMAN_NETWORK_OPTIONS ] as $key => $value ) {
|
208 |
+
$options[$key] = sanitize_text_field( $value );
|
209 |
+
|
210 |
+
if ( $value == 'null' ) {
|
211 |
+
unset( $options[$key] );
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
update_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS, $options );
|
216 |
+
} else {
|
217 |
+
update_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS, array() );
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
/**
|
222 |
* Functions to execute on the init event
|
223 |
*
|
Postman/PostmanInputSanitizer.php
CHANGED
@@ -69,14 +69,25 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) {
|
|
69 |
$this->sanitizeInt( 'Transcript Size', PostmanOptions::TRANSCRIPT_SIZE, $input, $new_input );
|
70 |
$this->sanitizeString( 'Temporary Directory', PostmanOptions::TEMPORARY_DIRECTORY, $input, $new_input );
|
71 |
|
|
|
72 |
$this->sanitizeString( 'Pushover Service', PostmanOptions::NOTIFICATION_SERVICE, $input, $new_input, $this->options->getNotificationService() );
|
73 |
$this->sanitizePassword( 'Pushover Username', PostmanOptions::PUSHOVER_USER, $input, $new_input, $this->options->getPushoverUser() );
|
74 |
$this->sanitizePassword( 'Pushover Token', PostmanOptions::PUSHOVER_TOKEN, $input, $new_input, $this->options->getPushoverToken() );
|
75 |
$this->sanitizePassword( 'Slack Token', PostmanOptions::SLACK_TOKEN, $input, $new_input, $this->options->getSlackToken() );
|
76 |
|
|
|
77 |
$this->sanitizeString( 'Push Chrome Extension', PostmanOptions::NOTIFICATION_USE_CHROME, $input, $new_input );
|
78 |
$this->sanitizePassword( 'Push Chrome Extension UID', PostmanOptions::NOTIFICATION_CHROME_UID, $input, $new_input, $this->options->getNotificationChromeUid() );
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
if ( $new_input [ PostmanOptions::CLIENT_ID ] != $this->options->getClientId() || $new_input [ PostmanOptions::CLIENT_SECRET ] != $this->options->getClientSecret() || $new_input [ PostmanOptions::HOSTNAME ] != $this->options->getHostname() ) {
|
81 |
$this->logger->debug( 'Recognized new Client ID' );
|
82 |
// the user entered a new client id and we should destroy the stored auth token
|
69 |
$this->sanitizeInt( 'Transcript Size', PostmanOptions::TRANSCRIPT_SIZE, $input, $new_input );
|
70 |
$this->sanitizeString( 'Temporary Directory', PostmanOptions::TEMPORARY_DIRECTORY, $input, $new_input );
|
71 |
|
72 |
+
// Notifications
|
73 |
$this->sanitizeString( 'Pushover Service', PostmanOptions::NOTIFICATION_SERVICE, $input, $new_input, $this->options->getNotificationService() );
|
74 |
$this->sanitizePassword( 'Pushover Username', PostmanOptions::PUSHOVER_USER, $input, $new_input, $this->options->getPushoverUser() );
|
75 |
$this->sanitizePassword( 'Pushover Token', PostmanOptions::PUSHOVER_TOKEN, $input, $new_input, $this->options->getPushoverToken() );
|
76 |
$this->sanitizePassword( 'Slack Token', PostmanOptions::SLACK_TOKEN, $input, $new_input, $this->options->getSlackToken() );
|
77 |
|
78 |
+
// Chrome extension
|
79 |
$this->sanitizeString( 'Push Chrome Extension', PostmanOptions::NOTIFICATION_USE_CHROME, $input, $new_input );
|
80 |
$this->sanitizePassword( 'Push Chrome Extension UID', PostmanOptions::NOTIFICATION_CHROME_UID, $input, $new_input, $this->options->getNotificationChromeUid() );
|
81 |
|
82 |
+
// Fallback
|
83 |
+
$this->sanitizeString( 'Use fallback', PostmanOptions::FALLBACK_SMTP_ENABLED, $input, $new_input );
|
84 |
+
$this->sanitizeString( 'Fallback hostname', PostmanOptions::FALLBACK_SMTP_HOSTNAME, $input, $new_input );
|
85 |
+
$this->sanitizeInt( 'Fallback port', PostmanOptions::FALLBACK_SMTP_PORT, $input, $new_input );
|
86 |
+
$this->sanitizeString( 'Fallback security', PostmanOptions::FALLBACK_SMTP_SECURITY, $input, $new_input );
|
87 |
+
$this->sanitizeString( 'Fallback auth', PostmanOptions::FALLBACK_SMTP_USE_AUTH, $input, $new_input );
|
88 |
+
$this->sanitizeString( 'Fallback username', PostmanOptions::FALLBACK_SMTP_USERNAME, $input, $new_input );
|
89 |
+
$this->sanitizePassword( 'Fallback password', PostmanOptions::FALLBACK_SMTP_PASSWORD, $input, $new_input, $this->options->getFallbackPassword() );
|
90 |
+
|
91 |
if ( $new_input [ PostmanOptions::CLIENT_ID ] != $this->options->getClientId() || $new_input [ PostmanOptions::CLIENT_SECRET ] != $this->options->getClientSecret() || $new_input [ PostmanOptions::HOSTNAME ] != $this->options->getHostname() ) {
|
92 |
$this->logger->debug( 'Recognized new Client ID' );
|
93 |
// the user entered a new client id and we should destroy the stored auth token
|
Postman/PostmanInstaller.php
CHANGED
@@ -12,6 +12,8 @@ require_once( 'PostmanOptions.php' );
|
|
12 |
class PostmanInstaller {
|
13 |
private $logger;
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
*/
|
17 |
public function __construct() {
|
@@ -22,16 +24,39 @@ class PostmanInstaller {
|
|
22 |
* Handle activation of the plugin
|
23 |
*/
|
24 |
public function activatePostman() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
// handle network activation
|
27 |
// from https://wordpress.org/support/topic/new-function-wp_get_sites?replies=11
|
28 |
// run the activation function for each blog id
|
29 |
$old_blog = get_current_blog_id();
|
30 |
// Get all blog ids
|
31 |
-
$subsites =
|
32 |
foreach ( $subsites as $subsite ) {
|
33 |
-
$this->logger->trace( 'multisite: switching to blog ' . $subsite
|
34 |
-
switch_to_blog( $subsite
|
35 |
$this->handleOptionUpdates();
|
36 |
$this->addCapability();
|
37 |
}
|
@@ -65,10 +90,10 @@ class PostmanInstaller {
|
|
65 |
// run the deactivation function for each blog id
|
66 |
$old_blog = get_current_blog_id();
|
67 |
// Get all blog ids
|
68 |
-
$subsites =
|
69 |
foreach ( $subsites as $subsite ) {
|
70 |
-
$this->logger->trace( 'multisite: switching to blog ' . $subsite
|
71 |
-
switch_to_blog( $subsite
|
72 |
$this->removeCapability();
|
73 |
}
|
74 |
switch_to_blog( $old_blog );
|
@@ -90,6 +115,7 @@ class PostmanInstaller {
|
|
90 |
// add the custom capability to the administrator role
|
91 |
$role = get_role( Postman::ADMINISTRATOR_ROLE_NAME );
|
92 |
$role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME );
|
|
|
93 |
}
|
94 |
|
95 |
/**
|
@@ -104,6 +130,7 @@ class PostmanInstaller {
|
|
104 |
// remove the custom capability from the administrator role
|
105 |
$role = get_role( Postman::ADMINISTRATOR_ROLE_NAME );
|
106 |
$role->remove_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME );
|
|
|
107 |
}
|
108 |
|
109 |
/**
|
12 |
class PostmanInstaller {
|
13 |
private $logger;
|
14 |
|
15 |
+
private $roles;
|
16 |
+
|
17 |
/**
|
18 |
*/
|
19 |
public function __construct() {
|
24 |
* Handle activation of the plugin
|
25 |
*/
|
26 |
public function activatePostman() {
|
27 |
+
$options = get_option( PostmanOptions::POSTMAN_OPTIONS );
|
28 |
+
$args = array(
|
29 |
+
'fallback_smtp_enabled' => 'no',
|
30 |
+
);
|
31 |
+
|
32 |
+
if ( empty( $options ) ) {
|
33 |
+
add_option( 'postman_options', $args );
|
34 |
+
|
35 |
+
} else {
|
36 |
+
if ( empty( $options['fallback_smtp_enabled'] ) ) {
|
37 |
+
$result = array_merge($options, $args);
|
38 |
+
update_option( PostmanOptions::POSTMAN_OPTIONS, $result );
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
43 |
+
|
44 |
+
/* $role = get_role( Postman::ADMINISTRATOR_ROLE_NAME );
|
45 |
+
$role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME );
|
46 |
+
$role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_LOGS );*/
|
47 |
+
|
48 |
+
$options['post_smtp_allow_overwrite'] = '1';
|
49 |
+
update_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS, $options );
|
50 |
+
|
51 |
// handle network activation
|
52 |
// from https://wordpress.org/support/topic/new-function-wp_get_sites?replies=11
|
53 |
// run the activation function for each blog id
|
54 |
$old_blog = get_current_blog_id();
|
55 |
// Get all blog ids
|
56 |
+
$subsites = get_sites();
|
57 |
foreach ( $subsites as $subsite ) {
|
58 |
+
$this->logger->trace( 'multisite: switching to blog ' . $subsite->blog_id );
|
59 |
+
switch_to_blog( $subsite->blog_id );
|
60 |
$this->handleOptionUpdates();
|
61 |
$this->addCapability();
|
62 |
}
|
90 |
// run the deactivation function for each blog id
|
91 |
$old_blog = get_current_blog_id();
|
92 |
// Get all blog ids
|
93 |
+
$subsites = get_sites();
|
94 |
foreach ( $subsites as $subsite ) {
|
95 |
+
$this->logger->trace( 'multisite: switching to blog ' . $subsite->blog_id );
|
96 |
+
switch_to_blog( $subsite->blog_id );
|
97 |
$this->removeCapability();
|
98 |
}
|
99 |
switch_to_blog( $old_blog );
|
115 |
// add the custom capability to the administrator role
|
116 |
$role = get_role( Postman::ADMINISTRATOR_ROLE_NAME );
|
117 |
$role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME );
|
118 |
+
$role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_LOGS );
|
119 |
}
|
120 |
|
121 |
/**
|
130 |
// remove the custom capability from the administrator role
|
131 |
$role = get_role( Postman::ADMINISTRATOR_ROLE_NAME );
|
132 |
$role->remove_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME );
|
133 |
+
$role->remove_cap( Postman::MANAGE_POSTMAN_CAPABILITY_LOGS );
|
134 |
}
|
135 |
|
136 |
/**
|
Postman/PostmanOptions.php
CHANGED
@@ -54,6 +54,7 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
54 |
|
55 |
// the option database name
|
56 |
const POSTMAN_OPTIONS = 'postman_options';
|
|
|
57 |
|
58 |
// the options fields
|
59 |
const VERSION = 'version';
|
@@ -112,6 +113,15 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
112 |
const PUSHOVER_TOKEN = 'pushover_token';
|
113 |
const SLACK_TOKEN = 'slack_token';
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
// defaults
|
116 |
const DEFAULT_TRANSCRIPT_SIZE = 128;
|
117 |
const DEFAULT_STEALTH_MODE = false;
|
@@ -127,6 +137,8 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
127 |
const DEFAULT_PLUGIN_MESSAGE_SENDER_EMAIL_ENFORCED = false;
|
128 |
const DEFAULT_TEMP_DIRECTORY = '/tmp';
|
129 |
|
|
|
|
|
130 |
// options data
|
131 |
private $options;
|
132 |
|
@@ -145,15 +157,36 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
145 |
private function __construct() {
|
146 |
$this->load();
|
147 |
}
|
|
|
148 |
public function save() {
|
149 |
-
|
150 |
}
|
|
|
151 |
public function reload() {
|
152 |
$this->load();
|
153 |
}
|
|
|
154 |
private function load() {
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
|
|
157 |
public function isNew() {
|
158 |
return ! isset( $this->options [ PostmanOptions::TRANSPORT_TYPE ] );
|
159 |
}
|
@@ -231,18 +264,41 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
231 |
return $this->options [ self::ADDITIONAL_HEADERS ]; }
|
232 |
}
|
233 |
public function getHostname() {
|
|
|
|
|
|
|
|
|
|
|
234 |
if ( isset( $this->options [ PostmanOptions::HOSTNAME ] ) ) {
|
235 |
return $this->options [ PostmanOptions::HOSTNAME ]; }
|
236 |
}
|
|
|
237 |
public function getPort() {
|
|
|
|
|
|
|
|
|
|
|
238 |
if ( isset( $this->options [ PostmanOptions::PORT ] ) ) {
|
239 |
return $this->options [ PostmanOptions::PORT ]; }
|
240 |
}
|
|
|
241 |
public function getEnvelopeSender() {
|
|
|
|
|
|
|
|
|
|
|
242 |
if ( isset( $this->options [ PostmanOptions::ENVELOPE_SENDER ] ) ) {
|
243 |
return $this->options [ PostmanOptions::ENVELOPE_SENDER ]; }
|
244 |
}
|
|
|
245 |
public function getMessageSenderEmail() {
|
|
|
|
|
|
|
|
|
|
|
246 |
if ( isset( $this->options [ PostmanOptions::MESSAGE_SENDER_EMAIL ] ) ) {
|
247 |
return $this->options [ PostmanOptions::MESSAGE_SENDER_EMAIL ]; }
|
248 |
}
|
@@ -258,21 +314,45 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
258 |
if ( isset( $this->options [ PostmanOptions::CLIENT_SECRET ] ) ) {
|
259 |
return $this->options [ PostmanOptions::CLIENT_SECRET ]; }
|
260 |
}
|
|
|
261 |
public function getTransportType() {
|
|
|
|
|
|
|
|
|
|
|
262 |
if ( isset( $this->options [ PostmanOptions::TRANSPORT_TYPE ] ) ) {
|
263 |
return $this->options [ PostmanOptions::TRANSPORT_TYPE ]; }
|
264 |
}
|
|
|
265 |
public function getAuthenticationType() {
|
|
|
|
|
|
|
|
|
|
|
266 |
if ( isset( $this->options [ PostmanOptions::AUTHENTICATION_TYPE ] ) ) {
|
267 |
return $this->options [ PostmanOptions::AUTHENTICATION_TYPE ]; }
|
268 |
}
|
|
|
269 |
public function getEncryptionType() {
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
if ( isset( $this->options [ PostmanOptions::SECURITY_TYPE ] ) ) {
|
271 |
return $this->options [ PostmanOptions::SECURITY_TYPE ];
|
272 |
}
|
273 |
}
|
274 |
|
275 |
public function getUsername() {
|
|
|
|
|
|
|
|
|
|
|
276 |
if ( defined( 'POST_SMTP_AUTH_USERNAME' ) ) {
|
277 |
return POST_SMTP_AUTH_USERNAME;
|
278 |
}
|
@@ -281,15 +361,77 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
281 |
return $this->options [ PostmanOptions::BASIC_AUTH_USERNAME ];
|
282 |
}
|
283 |
}
|
284 |
-
public function getPassword() {
|
285 |
-
if ( defined( 'POST_SMTP_AUTH_PASSWORD' ) ) {
|
286 |
-
return POST_SMTP_AUTH_PASSWORD;
|
287 |
-
}
|
288 |
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
public function getMandrillApiKey() {
|
294 |
if ( defined( 'POST_SMTP_API_KEY' ) ) {
|
295 |
return POST_SMTP_API_KEY;
|
@@ -376,10 +518,12 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
376 |
if ( isset( $this->options [ PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE ] ) ) {
|
377 |
return $this->options [ PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE ]; }
|
378 |
}
|
|
|
379 |
public function isEmailValidationDisabled() {
|
380 |
if ( isset( $this->options [ PostmanOptions::DISABLE_EMAIL_VALIDAITON ] ) ) {
|
381 |
return $this->options [ PostmanOptions::DISABLE_EMAIL_VALIDAITON ]; }
|
382 |
}
|
|
|
383 |
/**
|
384 |
* (non-PHPdoc)
|
385 |
*
|
@@ -390,6 +534,11 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
390 |
return $this->isPluginSenderEmailEnforced();
|
391 |
}
|
392 |
public function isPluginSenderEmailEnforced() {
|
|
|
|
|
|
|
|
|
|
|
393 |
if ( $this->isNew() ) {
|
394 |
return self::DEFAULT_PLUGIN_MESSAGE_SENDER_EMAIL_ENFORCED; }
|
395 |
if ( isset( $this->options [ PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE ] ) ) {
|
54 |
|
55 |
// the option database name
|
56 |
const POSTMAN_OPTIONS = 'postman_options';
|
57 |
+
const POSTMAN_NETWORK_OPTIONS = 'postman_network_options';
|
58 |
|
59 |
// the options fields
|
60 |
const VERSION = 'version';
|
113 |
const PUSHOVER_TOKEN = 'pushover_token';
|
114 |
const SLACK_TOKEN = 'slack_token';
|
115 |
|
116 |
+
// Fallback
|
117 |
+
const FALLBACK_SMTP_ENABLED = 'fallback_smtp_enabled';
|
118 |
+
const FALLBACK_SMTP_HOSTNAME = 'fallback_smtp_hostname';
|
119 |
+
const FALLBACK_SMTP_PORT = 'fallback_smtp_port';
|
120 |
+
const FALLBACK_SMTP_SECURITY = 'fallback_smtp_security';
|
121 |
+
const FALLBACK_SMTP_USE_AUTH = 'fallback_smtp_use_auth';
|
122 |
+
const FALLBACK_SMTP_USERNAME = 'fallback_smtp_username';
|
123 |
+
const FALLBACK_SMTP_PASSWORD = 'fallback_smtp_password';
|
124 |
+
|
125 |
// defaults
|
126 |
const DEFAULT_TRANSCRIPT_SIZE = 128;
|
127 |
const DEFAULT_STEALTH_MODE = false;
|
137 |
const DEFAULT_PLUGIN_MESSAGE_SENDER_EMAIL_ENFORCED = false;
|
138 |
const DEFAULT_TEMP_DIRECTORY = '/tmp';
|
139 |
|
140 |
+
public $is_fallback = false;
|
141 |
+
|
142 |
// options data
|
143 |
private $options;
|
144 |
|
157 |
private function __construct() {
|
158 |
$this->load();
|
159 |
}
|
160 |
+
|
161 |
public function save() {
|
162 |
+
update_option( PostmanOptions::POSTMAN_OPTIONS, $this->options );
|
163 |
}
|
164 |
+
|
165 |
public function reload() {
|
166 |
$this->load();
|
167 |
}
|
168 |
+
|
169 |
private function load() {
|
170 |
+
|
171 |
+
$options = get_option( self::POSTMAN_OPTIONS );
|
172 |
+
|
173 |
+
if ( is_multisite() ) {
|
174 |
+
$network_options = get_site_option( self::POSTMAN_NETWORK_OPTIONS );
|
175 |
+
|
176 |
+
if ( isset( $network_options['post_smtp_global_settings'] ) ) {
|
177 |
+
$blog_id = apply_filters( 'post_smtp_default_site_option', 1 );
|
178 |
+
} elseif ( $options && isset( $network_options['post_smtp_allow_overwrite'] ) ) {
|
179 |
+
$blog_id = get_current_blog_id();
|
180 |
+
}
|
181 |
+
|
182 |
+
switch_to_blog($blog_id);
|
183 |
+
$options = get_option( self::POSTMAN_OPTIONS );
|
184 |
+
restore_current_blog();
|
185 |
+
}
|
186 |
+
|
187 |
+
$this->options = $options;
|
188 |
}
|
189 |
+
|
190 |
public function isNew() {
|
191 |
return ! isset( $this->options [ PostmanOptions::TRANSPORT_TYPE ] );
|
192 |
}
|
264 |
return $this->options [ self::ADDITIONAL_HEADERS ]; }
|
265 |
}
|
266 |
public function getHostname() {
|
267 |
+
|
268 |
+
if ( $this->is_fallback ) {
|
269 |
+
return $this->getFallbackHostname();
|
270 |
+
}
|
271 |
+
|
272 |
if ( isset( $this->options [ PostmanOptions::HOSTNAME ] ) ) {
|
273 |
return $this->options [ PostmanOptions::HOSTNAME ]; }
|
274 |
}
|
275 |
+
|
276 |
public function getPort() {
|
277 |
+
|
278 |
+
if ( $this->is_fallback ) {
|
279 |
+
return $this->getFallbackPort();
|
280 |
+
}
|
281 |
+
|
282 |
if ( isset( $this->options [ PostmanOptions::PORT ] ) ) {
|
283 |
return $this->options [ PostmanOptions::PORT ]; }
|
284 |
}
|
285 |
+
|
286 |
public function getEnvelopeSender() {
|
287 |
+
|
288 |
+
if ( $this->is_fallback ) {
|
289 |
+
return $this->getFallbackUsername();
|
290 |
+
}
|
291 |
+
|
292 |
if ( isset( $this->options [ PostmanOptions::ENVELOPE_SENDER ] ) ) {
|
293 |
return $this->options [ PostmanOptions::ENVELOPE_SENDER ]; }
|
294 |
}
|
295 |
+
|
296 |
public function getMessageSenderEmail() {
|
297 |
+
|
298 |
+
if ( $this->is_fallback ) {
|
299 |
+
return $this->getFallbackUsername();
|
300 |
+
}
|
301 |
+
|
302 |
if ( isset( $this->options [ PostmanOptions::MESSAGE_SENDER_EMAIL ] ) ) {
|
303 |
return $this->options [ PostmanOptions::MESSAGE_SENDER_EMAIL ]; }
|
304 |
}
|
314 |
if ( isset( $this->options [ PostmanOptions::CLIENT_SECRET ] ) ) {
|
315 |
return $this->options [ PostmanOptions::CLIENT_SECRET ]; }
|
316 |
}
|
317 |
+
|
318 |
public function getTransportType() {
|
319 |
+
|
320 |
+
if ( $this->is_fallback ) {
|
321 |
+
return 'smtp';
|
322 |
+
}
|
323 |
+
|
324 |
if ( isset( $this->options [ PostmanOptions::TRANSPORT_TYPE ] ) ) {
|
325 |
return $this->options [ PostmanOptions::TRANSPORT_TYPE ]; }
|
326 |
}
|
327 |
+
|
328 |
public function getAuthenticationType() {
|
329 |
+
|
330 |
+
if ( $this->is_fallback ) {
|
331 |
+
return $this->getFallbackAuth();
|
332 |
+
}
|
333 |
+
|
334 |
if ( isset( $this->options [ PostmanOptions::AUTHENTICATION_TYPE ] ) ) {
|
335 |
return $this->options [ PostmanOptions::AUTHENTICATION_TYPE ]; }
|
336 |
}
|
337 |
+
|
338 |
public function getEncryptionType() {
|
339 |
+
|
340 |
+
if ( $this->is_fallback ) {
|
341 |
+
return $this->getFallbackSecurity();
|
342 |
+
}
|
343 |
+
|
344 |
+
|
345 |
if ( isset( $this->options [ PostmanOptions::SECURITY_TYPE ] ) ) {
|
346 |
return $this->options [ PostmanOptions::SECURITY_TYPE ];
|
347 |
}
|
348 |
}
|
349 |
|
350 |
public function getUsername() {
|
351 |
+
|
352 |
+
if ( $this->is_fallback ) {
|
353 |
+
return $this->getFallbackUsername();
|
354 |
+
}
|
355 |
+
|
356 |
if ( defined( 'POST_SMTP_AUTH_USERNAME' ) ) {
|
357 |
return POST_SMTP_AUTH_USERNAME;
|
358 |
}
|
361 |
return $this->options [ PostmanOptions::BASIC_AUTH_USERNAME ];
|
362 |
}
|
363 |
}
|
|
|
|
|
|
|
|
|
364 |
|
365 |
+
public function getPassword() {
|
366 |
+
|
367 |
+
if ( $this->is_fallback ) {
|
368 |
+
return $this->getFallbackPassword();
|
369 |
+
}
|
370 |
+
|
371 |
+
if ( defined( 'POST_SMTP_AUTH_PASSWORD' ) ) {
|
372 |
+
return POST_SMTP_AUTH_PASSWORD;
|
373 |
+
}
|
374 |
+
|
375 |
+
if ( isset( $this->options [ PostmanOptions::BASIC_AUTH_PASSWORD ] ) ) {
|
376 |
+
return base64_decode( $this->options [ PostmanOptions::BASIC_AUTH_PASSWORD ] );
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
// Fallback
|
381 |
+
public function getFallbackIsEnabled() {
|
382 |
+
if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_ENABLED ] ) ) {
|
383 |
+
return $this->options [ PostmanOptions::FALLBACK_SMTP_ENABLED ];
|
384 |
+
}
|
385 |
+
return false;
|
386 |
+
}
|
387 |
+
|
388 |
+
public function getFallbackHostname() {
|
389 |
+
if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_HOSTNAME ] ) ) {
|
390 |
+
return $this->options [ PostmanOptions::FALLBACK_SMTP_HOSTNAME ];
|
391 |
+
}
|
392 |
+
}
|
393 |
+
|
394 |
+
public function getFallbackPort() {
|
395 |
+
if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_PORT ] ) ) {
|
396 |
+
return $this->options [ PostmanOptions::FALLBACK_SMTP_PORT ];
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
public function getFallbackSecurity() {
|
401 |
+
if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_SECURITY ] ) ) {
|
402 |
+
return $this->options [ PostmanOptions::FALLBACK_SMTP_SECURITY ];
|
403 |
+
}
|
404 |
+
}
|
405 |
+
|
406 |
+
public function getFallbackAuth() {
|
407 |
+
if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_USE_AUTH ] ) ) {
|
408 |
+
return $this->options [ PostmanOptions::FALLBACK_SMTP_USE_AUTH ];
|
409 |
+
}
|
410 |
+
}
|
411 |
+
|
412 |
+
public function getFallbackUsername() {
|
413 |
+
if ( defined( 'POST_SMTP_FALLBACK_AUTH_USERNAME' ) ) {
|
414 |
+
return POST_SMTP_FALLBACK_AUTH_USERNAME;
|
415 |
+
}
|
416 |
+
|
417 |
+
if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_USERNAME ] ) ) {
|
418 |
+
return $this->options [ PostmanOptions::FALLBACK_SMTP_USERNAME ];
|
419 |
+
}
|
420 |
+
}
|
421 |
+
|
422 |
+
|
423 |
+
public function getFallbackPassword() {
|
424 |
+
if ( defined( 'POST_SMTP_FALLBACK_AUTH_PASSWORD' ) ) {
|
425 |
+
return POST_SMTP_FALLBACK_AUTH_PASSWORD;
|
426 |
+
}
|
427 |
+
|
428 |
+
if ( isset( $this->options [ PostmanOptions::FALLBACK_SMTP_PASSWORD ] ) ) {
|
429 |
+
return base64_decode( $this->options [ PostmanOptions::FALLBACK_SMTP_PASSWORD ] );
|
430 |
+
}
|
431 |
+
}
|
432 |
+
|
433 |
+
// End Fallback
|
434 |
+
|
435 |
public function getMandrillApiKey() {
|
436 |
if ( defined( 'POST_SMTP_API_KEY' ) ) {
|
437 |
return POST_SMTP_API_KEY;
|
518 |
if ( isset( $this->options [ PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE ] ) ) {
|
519 |
return $this->options [ PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE ]; }
|
520 |
}
|
521 |
+
|
522 |
public function isEmailValidationDisabled() {
|
523 |
if ( isset( $this->options [ PostmanOptions::DISABLE_EMAIL_VALIDAITON ] ) ) {
|
524 |
return $this->options [ PostmanOptions::DISABLE_EMAIL_VALIDAITON ]; }
|
525 |
}
|
526 |
+
|
527 |
/**
|
528 |
* (non-PHPdoc)
|
529 |
*
|
534 |
return $this->isPluginSenderEmailEnforced();
|
535 |
}
|
536 |
public function isPluginSenderEmailEnforced() {
|
537 |
+
|
538 |
+
if ( $this->is_fallback ) {
|
539 |
+
return true;
|
540 |
+
}
|
541 |
+
|
542 |
if ( $this->isNew() ) {
|
543 |
return self::DEFAULT_PLUGIN_MESSAGE_SENDER_EMAIL_ENFORCED; }
|
544 |
if ( isset( $this->options [ PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE ] ) ) {
|
Postman/PostmanUtils.php
CHANGED
@@ -36,6 +36,10 @@ class PostmanUtils {
|
|
36 |
* @return string
|
37 |
*/
|
38 |
public static function getPageUrl( $slug ) {
|
|
|
|
|
|
|
|
|
39 |
return get_admin_url() . 'admin.php?page=' . $slug;
|
40 |
}
|
41 |
|
@@ -393,6 +397,7 @@ class PostmanUtils {
|
|
393 |
if ( $logger->isTrace() ) {
|
394 |
$logger->trace( 'Registering admin menu ' . $callbackName );
|
395 |
}
|
|
|
396 |
add_action( 'admin_menu', array(
|
397 |
$viewController,
|
398 |
$callbackName,
|
36 |
* @return string
|
37 |
*/
|
38 |
public static function getPageUrl( $slug ) {
|
39 |
+
if ( is_network_admin() ) {
|
40 |
+
return network_admin_url( 'admin.php?page=' . $slug );
|
41 |
+
}
|
42 |
+
|
43 |
return get_admin_url() . 'admin.php?page=' . $slug;
|
44 |
}
|
45 |
|
397 |
if ( $logger->isTrace() ) {
|
398 |
$logger->trace( 'Registering admin menu ' . $callbackName );
|
399 |
}
|
400 |
+
|
401 |
add_action( 'admin_menu', array(
|
402 |
$viewController,
|
403 |
$callbackName,
|
Postman/PostmanViewController.php
CHANGED
@@ -38,10 +38,12 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
38 |
add_action( 'admin_init', array( $this, 'registerStylesAndScripts' ), 0 );
|
39 |
add_action( 'wp_ajax_delete_lock_file', array( $this, 'delete_lock_file' ) );
|
40 |
add_action( 'wp_ajax_dismiss_version_notify', array( $this, 'dismiss_version_notify' ) );
|
|
|
41 |
//add_action( 'admin_init', array( $this, 'do_activation_redirect' ) );
|
42 |
|
43 |
}
|
44 |
|
|
|
45 |
function dismiss_version_notify() {
|
46 |
check_ajax_referer( 'postsmtp', 'security' );
|
47 |
|
@@ -307,7 +309,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
307 |
echo '
|
308 |
<div class="updated settings-error notice is-dismissible">
|
309 |
<p>
|
310 |
-
<strong>Version ' . $version . '
|
311 |
</p>
|
312 |
<button style="z-index: 100;" data-version="'. $version . '" data-security="' . wp_create_nonce('postsmtp') .'" type="button" class="notice-dismiss postman-release-message">
|
313 |
<span class="screen-reader-text">Dismiss this notice.</span>
|
38 |
add_action( 'admin_init', array( $this, 'registerStylesAndScripts' ), 0 );
|
39 |
add_action( 'wp_ajax_delete_lock_file', array( $this, 'delete_lock_file' ) );
|
40 |
add_action( 'wp_ajax_dismiss_version_notify', array( $this, 'dismiss_version_notify' ) );
|
41 |
+
|
42 |
//add_action( 'admin_init', array( $this, 'do_activation_redirect' ) );
|
43 |
|
44 |
}
|
45 |
|
46 |
+
|
47 |
function dismiss_version_notify() {
|
48 |
check_ajax_referer( 'postsmtp', 'security' );
|
49 |
|
309 |
echo '
|
310 |
<div class="updated settings-error notice is-dismissible">
|
311 |
<p>
|
312 |
+
<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>
|
313 |
</p>
|
314 |
<button style="z-index: 100;" data-version="'. $version . '" data-security="' . wp_create_nonce('postsmtp') .'" type="button" class="notice-dismiss postman-release-message">
|
315 |
<span class="screen-reader-text">Dismiss this notice.</span>
|
Postman/PostmanWpMail.php
CHANGED
@@ -235,6 +235,13 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
|
|
235 |
PostmanEmailLogService::getInstance()->writeFailureLog( $log, $message, $engine->getTranscript(), $transport, $e->getMessage() );
|
236 |
}
|
237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
$mail_error_data = array(
|
239 |
'to' => $message->getToRecipients(),
|
240 |
'subject' => $message->getSubject(),
|
@@ -248,9 +255,29 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
|
|
248 |
|
249 |
// return failure
|
250 |
return false;
|
|
|
251 |
}
|
252 |
}
|
253 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
/**
|
255 |
* Clean up after sending the mail
|
256 |
*
|
235 |
PostmanEmailLogService::getInstance()->writeFailureLog( $log, $message, $engine->getTranscript(), $transport, $e->getMessage() );
|
236 |
}
|
237 |
|
238 |
+
// Fallback
|
239 |
+
if ( $this->fallback( $log, $message, $options ) ) {
|
240 |
+
|
241 |
+
return true;
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
$mail_error_data = array(
|
246 |
'to' => $message->getToRecipients(),
|
247 |
'subject' => $message->getSubject(),
|
255 |
|
256 |
// return failure
|
257 |
return false;
|
258 |
+
|
259 |
}
|
260 |
}
|
261 |
|
262 |
+
private function fallback( $log, $postMessage,$options ) {
|
263 |
+
|
264 |
+
if ( ! $options->is_fallback && $options->getFallbackIsEnabled() && $options->getFallbackIsEnabled() == 'yes' ) {
|
265 |
+
|
266 |
+
$options->is_fallback = true;
|
267 |
+
|
268 |
+
$status = $this->sendMessage( $postMessage, $log );
|
269 |
+
|
270 |
+
$options->is_fallback = false;
|
271 |
+
|
272 |
+
return $status;
|
273 |
+
|
274 |
+
} else {
|
275 |
+
$options->is_fallback = false;
|
276 |
+
}
|
277 |
+
|
278 |
+
return false;
|
279 |
+
}
|
280 |
+
|
281 |
/**
|
282 |
* Clean up after sending the mail
|
283 |
*
|
postman-smtp.php
CHANGED
@@ -3,14 +3,17 @@
|
|
3 |
* Plugin Name: Post SMTP
|
4 |
* Plugin URI: https://wordpress.org/plugins/post-smtp/
|
5 |
* 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!
|
6 |
-
* Version: 1.9.
|
7 |
-
* Author:
|
8 |
* Text Domain: post-smtp
|
9 |
* Author URI: https://postmansmtp.com
|
10 |
* License: GPLv2 or later
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
|
|
|
|
|
|
|
14 |
// The Postman Mail API
|
15 |
//
|
16 |
// filter postman_test_email: before calling wp_mail, implement this filter and return true to disable the success/fail counters
|
@@ -28,8 +31,9 @@
|
|
28 |
// -- class autoloading
|
29 |
// -- Add dismiss option for "unconfigured message" .. for multisites
|
30 |
// -- customize sent-mail icon WordPress dashboard
|
31 |
-
// -- 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.
|
32 |
// -- multiple mailbox support
|
|
|
|
|
33 |
/**
|
34 |
* DO some check and Start Postman
|
35 |
*/
|
@@ -122,5 +126,5 @@ function post_start( $startingMemory ) {
|
|
122 |
*/
|
123 |
function post_setupPostman() {
|
124 |
require_once 'Postman/Postman.php';
|
125 |
-
$kevinCostner = new Postman( __FILE__, '1.9.
|
126 |
}
|
3 |
* Plugin Name: Post SMTP
|
4 |
* Plugin URI: https://wordpress.org/plugins/post-smtp/
|
5 |
* 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!
|
6 |
+
* Version: 1.9.7
|
7 |
+
* Author: Yehuda Hassine
|
8 |
* Text Domain: post-smtp
|
9 |
* Author URI: https://postmansmtp.com
|
10 |
* License: GPLv2 or later
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
|
14 |
+
/*
|
15 |
+
* Post SMTP (aka Postman SMTP) was originally developed by Jason Hendriks
|
16 |
+
*/
|
17 |
// The Postman Mail API
|
18 |
//
|
19 |
// filter postman_test_email: before calling wp_mail, implement this filter and return true to disable the success/fail counters
|
31 |
// -- class autoloading
|
32 |
// -- Add dismiss option for "unconfigured message" .. for multisites
|
33 |
// -- customize sent-mail icon WordPress dashboard
|
|
|
34 |
// -- multiple mailbox support
|
35 |
+
|
36 |
+
|
37 |
/**
|
38 |
* DO some check and Start Postman
|
39 |
*/
|
126 |
*/
|
127 |
function post_setupPostman() {
|
128 |
require_once 'Postman/Postman.php';
|
129 |
+
$kevinCostner = new Postman( __FILE__, '1.9.7' );
|
130 |
}
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Post SMTP Mailer/Email Log ===
|
2 |
-
Contributors: yehudah
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+PostSMTP
|
4 |
Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email, office365, mailgun
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 5.0.3
|
7 |
-
Stable tag: 1.9.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -12,8 +12,9 @@ Send, log and troubleshoot your Outgoing Email easily. Supports everything: SMTP
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
= Version 1.9.
|
16 |
-
|
|
|
17 |
|
18 |
= The Only SMTP plugin with chrome Notifications =
|
19 |
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.
|
|
92 |
|
93 |
= CREDITS =
|
94 |
|
95 |
-
Post SMTP (aka Postman SMTP) plugin was originally created by Jason Hendriks.
|
96 |
|
97 |
== Installation ==
|
98 |
|
@@ -289,13 +290,20 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a
|
|
289 |
|
290 |
== Changelog ==
|
291 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
= 1.9.6 - 2019-01-29
|
293 |
* Added support for our new chrome notification extension.
|
294 |
* few fixes
|
295 |
|
296 |
= 1.9.5 - 2018-10-02
|
297 |
* Added support for Mailgun Europe region.
|
298 |
-
* Replace "
|
299 |
|
300 |
= 1.9.4 - 2018-08-03
|
301 |
The most stupid idea ever remove (auto security select)
|
1 |
=== Post SMTP Mailer/Email Log ===
|
2 |
+
Contributors: yehudah
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+PostSMTP
|
4 |
Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email, office365, mailgun
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 5.0.3
|
7 |
+
Stable tag: 1.9.7
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
= Version 1.9.7 released - The SMTP Fallback =
|
16 |
+
A fallback is a unique solution only exist on Post SMTP.
|
17 |
+
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/)
|
18 |
|
19 |
= The Only SMTP plugin with chrome Notifications =
|
20 |
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)
|
93 |
|
94 |
= CREDITS =
|
95 |
|
96 |
+
Post SMTP (aka Postman SMTP) plugin was originally created by Jason Hendriks.
|
97 |
|
98 |
== Installation ==
|
99 |
|
290 |
|
291 |
== Changelog ==
|
292 |
|
293 |
+
= 1.9.7 - 2019-02-17
|
294 |
+
* New: Fallback Feature - Configure a backup SMTP when emails are failing.
|
295 |
+
* New: WordPress Multisite compability - with global settings.
|
296 |
+
* New: Email Log capability - give other user cheking the logs.
|
297 |
+
* Fixed: compatibility with mailster plugin
|
298 |
+
* Fixed: Mandrill exception bug - Thanks to Niels de Blaauw from Level-Level
|
299 |
+
|
300 |
= 1.9.6 - 2019-01-29
|
301 |
* Added support for our new chrome notification extension.
|
302 |
* few fixes
|
303 |
|
304 |
= 1.9.5 - 2018-10-02
|
305 |
* Added support for Mailgun Europe region.
|
306 |
+
* Replace "buggy" mime_content_type php function
|
307 |
|
308 |
= 1.9.4 - 2018-08-03
|
309 |
The most stupid idea ever remove (auto security select)
|