aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-03-04 21:10:18 +0100
committerThomas Mueller <thomas.mueller@tmit.eu>2013-03-04 21:10:18 +0100
commit6019cdd5bdba8623673299e9ae7b765bef8235a9 (patch)
tree9ee783399c7b6cbf11a0cdde7dae57de7bbe4a0f
parentee00ddeb60b98b9a817bc93afea5bf9e410e612b (diff)
downloadnextcloud-server-6019cdd5bdba8623673299e9ae7b765bef8235a9.tar.gz
nextcloud-server-6019cdd5bdba8623673299e9ae7b765bef8235a9.zip
adding test case for getDefaultEmailAddress() + fixing #1844 again
-rw-r--r--lib/mail.php8
-rw-r--r--lib/public/util.php4
-rw-r--r--tests/lib/util.php5
3 files changed, 15 insertions, 2 deletions
diff --git a/lib/mail.php b/lib/mail.php
index 22194045a76..61634632efc 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 5d814114a24..db07cbcfff3 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 ebff3c7381a..b904c359807 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