diff --git a/plugins/newmail_notifier/newmail_notifier.js b/plugins/newmail_notifier/newmail_notifier.js index 3ff50f7e786..c57c60e7602 100644 --- a/plugins/newmail_notifier/newmail_notifier.js +++ b/plugins/newmail_notifier/newmail_notifier.js @@ -37,18 +37,16 @@ function newmail_notifier_run(prop) { newmail_notifier_sound(); } if (prop.desktop) { - var title = prop.from || rcmail.get_label('title', 'newmail_notifier'); - var body = prop.subject || rcmail.get_label('body', 'newmail_notifier'); - - // If there's more than one unread email, show the number of other emails - var otherCount = prop.count - 1; - if (otherCount >= 1) { - title += prop.from - // Have sender name, e.g. "Daniel L +3" - ? ' +' +otherCount - // No sender name, e.g. "New Mail! (3) - : '('+otherCount + ')'; + var title; + var body; + if (prop.count === 1) { + title = prop.from || rcmail.get_label('title', 'newmail_notifier'); + body = prop.subject || rcmail.get_label('body', 'newmail_notifier'); + } else { + title = '(' + prop.count + ') ' + rcmail.get_label('title', 'newmail_notifier'); + body = rcmail.get_label('body', 'newmail_notifier'); } + newmail_notifier_desktop(title, body); } } diff --git a/plugins/newmail_notifier/newmail_notifier.php b/plugins/newmail_notifier/newmail_notifier.php index c745de068ce..2f5f3c43d46 100644 --- a/plugins/newmail_notifier/newmail_notifier.php +++ b/plugins/newmail_notifier/newmail_notifier.php @@ -210,10 +210,15 @@ public function notify($args) if ($latest_uid !== null) { $headers = $storage->fetch_headers($mbox, [$latest_uid]); // fetch_headers returns an array, but we only care about the first one. - $headers = array_shift($headers); + $headers = array_first($headers); if ($headers !== null) { - $from = $headers->from; - $subject = $headers->subject; + $subject = trim( + rcube_mime::decode_header($headers->subject, $headers->charset) + ); + $from_details = array_first( + rcube_mime::decode_address_list($headers->from, 1, true, $headers->charset) + ); + $from = $from_details['name']; } }