diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php
index 424ee622303f2c84e332421fbaf41c2770b76a2a..81ba6ce474ea4b80620b4bf6098f964343e3d0a4 100644
--- a/server/plugins-available/mail_plugin.inc.php
+++ b/server/plugins-available/mail_plugin.inc.php
@@ -100,7 +100,7 @@ class mail_plugin {
 				$email_parts = explode('@',$data['new']['email']);
 				$webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain = '".$app->db->quote($email_parts[1])."'");
 				if ($webdomain) {
-					while ($webdomain['parent_domain_id'] != 0) {
+					while (($webdomain['system_user'] == null) && ($webdomain['parent_domain_id'] != 0)) {
 						$webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain_id = '".$webdomain['parent_domain_id']."'");
 					}
 					$app->log($data['new']['server_id'].' == '.$webdomain['server_id'],LOGLEVEL_DEBUG);