diff --git a/lib/mail.php b/lib/mail.php index 22194045a7..61634632ef 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -119,4 +119,12 @@ class OC_Mail { return($txt); } + + /** + * @param string $emailAddress a given email address to be validated + * @return bool + */ + public static function ValidateAddress($emailAddress) { + return PHPMailer::ValidateAddress($emailAddress); + } } diff --git a/lib/public/util.php b/lib/public/util.php index 5d814114a2..db07cbcfff 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -219,11 +219,11 @@ class Util { $host_name = self::getServerHostName(); $defaultEmailAddress = $user_part.'@'.$host_name; - if (\PHPMailer::ValidateAddress($defaultEmailAddress)) { + if (\OC_Mail::ValidateAddress($defaultEmailAddress)) { return $defaultEmailAddress; } - // incase we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain' + // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain' return $user_part.'@localhost.localdomain'; } diff --git a/tests/lib/util.php b/tests/lib/util.php index ebff3c7381..b904c35980 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -42,4 +42,9 @@ class Test_Util extends PHPUnit_Framework_TestCase { $result = strlen(OC_Util::generate_random_bytes(59)); $this->assertEquals(59, $result); } + + function testGetDefaultEmailAddress() { + $email = \OCP\Util::getDefaultEmailAddress("no-reply"); + $this->assertEquals('no-reply@localhost.localdomain', $email); + } } \ No newline at end of file