summaryrefslogtreecommitdiff
path: root/Postman/Postman-Email-Log
diff options
context:
space:
mode:
Diffstat (limited to 'Postman/Postman-Email-Log')
-rw-r--r--Postman/Postman-Email-Log/PostmanEmailLogService.php34
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;
}
}