Disable email notifications for disabled / banned users
authorTim Düsterhus <duesterhus@woltlab.com>
Sun, 19 Apr 2015 20:40:30 +0000 (22:40 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sun, 19 Apr 2015 20:50:59 +0000 (22:50 +0200)
- A user being disabled usually means that his email is
  not yet verified by proper double opt-in.
- A banned user has no means of changing his notification
  settings.

In both cases emails may have increased odds of being
moved into the Junk folder by the recipient and as a
consequence hurting the reputation of the sending mail
server.

see 0290c038a0f12431d0adeaf803cdd44d06fc086f

wcfsetup/install/files/lib/system/cronjob/DailyMailNotificationCronjob.class.php
wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php

index ba6bf173f5614619ebd704856eb59d859ee492ee..2cf66e346157b0871cd45699fc8d2965afe50a31 100644 (file)
@@ -140,6 +140,10 @@ class DailyMailNotificationCronjob extends AbstractCronjob {
                        if (!isset($users[$userID])) continue;
                        $user = $users[$userID];
                        
+                       // no notifications for disabled or banned users
+                       if ($user->activationCode) continue;
+                       if ($user->banned) continue;
+                       
                        // add mail header
                        $message = $user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.header', array(
                                'user' => $user
index 945426fa1a87e44f46749531dacb466804cf9a79..f7fc6f291e0b3c624676af09d960701694ce1f69 100644 (file)
@@ -617,6 +617,10 @@ class UserNotificationHandler extends SingletonFactory {
         * @param       \wcf\system\user\notification\event\IUserNotificationEvent      $event
         */
        public function sendInstantMailNotification(UserNotification $notification, User $user, IUserNotificationEvent $event) {
+               // no notifications for disabled or banned users
+               if ($user->activationCode) return;
+               if ($user->banned) return;
+               
                // recipient's language
                $event->setLanguage($user->getLanguage());