diff options
Diffstat (limited to 'Postman/Extensions')
-rw-r--r-- | Postman/Extensions/Core/Notifications/PostmanPushoverNotify.php | 4 | ||||
-rw-r--r-- | Postman/Extensions/Core/StatusSolution.php | 56 | ||||
-rw-r--r-- | Postman/Extensions/License/PostmanLicenseManager.php | 6 |
3 files changed, 60 insertions, 6 deletions
diff --git a/Postman/Extensions/Core/Notifications/PostmanPushoverNotify.php b/Postman/Extensions/Core/Notifications/PostmanPushoverNotify.php index 14ef7d2..c1f2661 100644 --- a/Postman/Extensions/Core/Notifications/PostmanPushoverNotify.php +++ b/Postman/Extensions/Core/Notifications/PostmanPushoverNotify.php @@ -6,7 +6,7 @@ class PostmanPushoverNotify implements Postman_Notify { public function send_message($message) { - $options = PostmanOptions::getInstance(); + $options = PostmanNotifyOptions::getInstance(); $api_url = "https://api.pushover.net/1/messages.json"; $app_token = $options->getPushoverToken(); @@ -31,4 +31,4 @@ class PostmanPushoverNotify implements Postman_Notify { error_log( __CLASS__ . ': ' . print_r( $body, true ) ); } } -}
\ No newline at end of file +} diff --git a/Postman/Extensions/Core/StatusSolution.php b/Postman/Extensions/Core/StatusSolution.php new file mode 100644 index 0000000..67ac768 --- /dev/null +++ b/Postman/Extensions/Core/StatusSolution.php @@ -0,0 +1,56 @@ +<?php + +class StatusSolution { + + private $status; + + public function __construct() { + add_filter( 'post_smtp_log_solution', array( $this, 'find_solution' ), 10, 4 ); + } + + public function find_solution( $solution, $status, $log, $message ) { + + if ( empty( $status ) ) { + return 'All good, mail sent.'; + } + + $this->status = addslashes( $status ); + $possible_solution = []; + + if ( $this->strExists('timed out') ) { + $possible_solution[] = $this->make_clickable('https://postmansmtp.com/office365-smtp-connection-timed-out/'); + } elseif ( $this->strExists('timeout') || $this->strExists('open socket' ) ) { + $possible_solution[] = 'Your hosting is blocking the connection, contact their support'; + } elseif ( $this->strExists( 'DATA NOT ACCEPTED' ) || $this->strExists('Exception:SendAsDeniedException' ) ) { + $possible_solution[] = $this->make_clickable('https://postmansmtp.com/storedrv-submission-exceptionsendasdeniedexception-mapiexceptionsendasdenied/'); + } elseif ( $this->strExists( 'Incorrect authentication data') ) { + $possible_solution[] = $this->make_clickable( 'https://postmansmtp.com/incorrect-authentication-data/' ); + } elseif ( $this->strExists( 'Unrecognized authentication type' ) ) { + $possible_solution[] = 'Change "Authentication" type on plugin settings to "Login"'; + } elseif ( $this->strExists( 'Error executing "SendRawEmail"' ) ) { + $possible_solution[] = 'Amazon SES - account permission error (review account configuration)'; + } elseif ( $this->strExists( 'Please log in via your web browser and then try again' ) ) { + $possible_solution[] = $this->make_clickable( 'https://postmansmtp.com/gmail-gsuite-please-log-in-via-your-web-browser-and-then-try-again/' ); + } elseif ( $this->strExists( 'Application-specific password required' ) ) { + $possible_solution[] = 'Two factor authentication is enabled, replace your password with app password.'; + $possible_solution[] = $this->make_clickable( 'https://support.google.com/mail/?p=InvalidSecondFactor' ); + } elseif ( $this->strExists( 'Username and Password not accepted' ) || $this->strExists( 'Authentication unsuccessful' ) ) { + $possible_solution[] = 'Check you credentials, wrong email or password.'; + } else { + $possible_solution[] = 'Not found, check status column for more info.'; + } + + return ! empty( $possible_solution ) ? implode( '<br>', $possible_solution ) : ''; + } + + private function make_clickable($url) { + return '<a target="_blank" href="' . esc_url($url ) . '">' . esc_html( 'Read here' ) . '</a>'; + } + + private function strExists( $value ) { + return strpos( strtolower( $this->status ), strtolower( addslashes( $value ) ) ) !== false; + } + +} + +new StatusSolution();
\ No newline at end of file diff --git a/Postman/Extensions/License/PostmanLicenseManager.php b/Postman/Extensions/License/PostmanLicenseManager.php index 280b564..cb10852 100644 --- a/Postman/Extensions/License/PostmanLicenseManager.php +++ b/Postman/Extensions/License/PostmanLicenseManager.php @@ -68,11 +68,9 @@ class PostmanLicenseManager { $this->extensions[$slug]['plugin_dir_and_filename'] = $plugin_dir_and_filename; $this->extensions[$slug]['license_manager'] = new PostmanLicenseHandler( $plugin_path, $plugin_data['Name'], - $plugin_data['Version'], $plugin_data['Author'] + $plugin_data['Version'], $plugin_data['Author'], null, self::ENDPOINT ); if ( $this->extensions[$slug]['license_manager']->is_licensed() ) { - include_once $plugin_path; - $this->extensions[$slug]['instance'] = new $class; } } @@ -99,4 +97,4 @@ class PostmanLicenseManager { public function get_extensions() { return $this->extensions; } -}
\ No newline at end of file +} |