diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index a812e90..de8fda3 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -2266,7 +2266,18 @@ function over_bounce_threshold($user) {
     if ($send = get_record('user_preferences','userid',$user->id,'name','email_send_count')) {
         $sendcount = $send->value;
     }
-    return ($bouncecount >= $CFG->minbounces && $bouncecount/$sendcount >= $CFG->bounceratio);
+
+    $overlimit = ($bouncecount >= $CFG->minbounces && $bouncecount/$sendcount >= $CFG->bounceratio);
+
+    if($overlimit && !empty($CFG->disableemailwhenbounced)){
+        if($user->emailstop){
+            return false;
+        }else{
+            set_field('user', 'emailstop', 1, 'id', $user->id);
+        }
+    }
+
+    return $overlimit;
 }
