diff options
author | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2018-04-04 19:17:51 +0000 |
---|---|---|
committer | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2018-04-04 19:17:51 +0000 |
commit | 62b95f35576ea9b9178b900f9480fed0466211a2 (patch) | |
tree | 746cfdf1c0cdc8408b312870f881ed3684d8d60b /Postman/Postman-Email-Log | |
parent | a83767b57bb15075e775f2336cfd77225b155799 (diff) | |
download | Post-SMTP-62b95f35576ea9b9178b900f9480fed0466211a2.zip |
notification & new gmail client
Diffstat (limited to 'Postman/Postman-Email-Log')
-rw-r--r-- | Postman/Postman-Email-Log/PostmanEmailLogService.php | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/Postman/Postman-Email-Log/PostmanEmailLogService.php b/Postman/Postman-Email-Log/PostmanEmailLogService.php index a087916..ebb2e54 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogService.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogService.php @@ -157,19 +157,41 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) { private function checkForLogErrors( PostmanEmailLog $log ) { $message = __( 'You getting this message because an error detected while delivered your email.', Postman::TEXT_DOMAIN ); - $message .= "\r\n" . __( 'You are welcome to post a support issue.', Postman::TEXT_DOMAIN ); - $message .= "\r\n" . __( 'The log to paste with your support issue:', Postman::TEXT_DOMAIN ) . "\r\n"; + $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"; - $to_email = get_bloginfo( 'admin_email' ); - $domain = get_bloginfo( 'url' ); if ( $log->statusMessage && ! empty( $log->statusMessage ) ) { - mail( $to_email, "{$domain}: " . __( 'Post SMTP email error', Postman::TEXT_DOMAIN ), $message . $log->statusMessage, null, "-f{$to_email}" ); + require_once POST_PATH . '/Postman/notifications/PostmanNotify.php'; + + $message = $message . $log->statusMessage; + + $notification_service = PostmanOptions::getInstance()->getNotificationService(); + switch ($notification_service) { + case 'default': + $notifyer = new PostmanMailNotify; + break; + case 'pushover': + $notifyer = new PostmanPushoverNotify; + break; + case 'slack': + $notifyer = new PostmanSlackNotify; + break; + default: + $notifyer = new PostmanMailNotify; + } + + $notify = new PostmanNotify( $notifyer, $message ); + $notify->send($message, $log); } + /** + * @todo + * After commented by me, check if it was needed. + */ preg_match_all( '/(.*)From/s', $log->sessionTranscript, $matches ); if ( isset( $matches[1][0] ) && ! empty( $matches[1][0] ) && strpos( strtolower( $matches[1][0] ), 'error' ) !== false ) { - mail( $to_email, "{$domain}: " . __( 'Post SMTP session transcript error', Postman::TEXT_DOMAIN ), $message . $log->sessionTranscript, null, "-f{$to_email}" ); + $message = $message . $log->sessionTranscript; } } |