]> source.dussan.org Git - nextcloud-server.git/commitdiff
validate the generated email address and fall back to localhost.localdomain in case...
authorThomas Mueller <thomas.mueller@tmit.eu>
Fri, 1 Mar 2013 21:24:19 +0000 (22:24 +0100)
committerThomas Mueller <thomas.mueller@tmit.eu>
Fri, 1 Mar 2013 21:24:19 +0000 (22:24 +0100)
fixes #1844

lib/public/util.php

index 13498b260ef88990f4f626f313cb332552d18ce1..5d814114a248ec05a11ada5c11e6be2b40545592 100644 (file)
@@ -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';
        }
 
        /**