From 6c304fa5c0864dd882415b701dc24e6fd9249daa Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 1 Mar 2013 22:24:19 +0100 Subject: [PATCH] validate the generated email address and fall back to localhost.localdomain in case it is not valid fixes #1844 --- lib/public/util.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/public/util.php b/lib/public/util.php index 13498b260ef..5d814114a24 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -217,11 +217,14 @@ class Util { */ public static function getDefaultEmailAddress($user_part) { $host_name = self::getServerHostName(); - // handle localhost installations - if ($host_name === 'localhost') { - $host_name = "example.com"; + $defaultEmailAddress = $user_part.'@'.$host_name; + + if (\PHPMailer::ValidateAddress($defaultEmailAddress)) { + return $defaultEmailAddress; } - return $user_part.'@'.$host_name; + + // incase we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain' + return $user_part.'@localhost.localdomain'; } /** -- 2.39.5