aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/config.sample.php3
-rw-r--r--lib/public/util.php1
-rw-r--r--tests/lib/util.php9
3 files changed, 12 insertions, 1 deletions
diff --git a/config/config.sample.php b/config/config.sample.php
index ec61ceefd6c..995a02f6d94 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -77,6 +77,9 @@ $CONFIG = array(
/* URL of the appstore to use, server should understand OCS */
"appstoreurl" => "http://api.apps.owncloud.com/v1",
+/* Domain name used by ownCloud for the sender mail address, e.g. no-reply@example.com */
+"mail_domain" => "example.com",
+
/* Enable SMTP class debugging */
"mail_smtpdebug" => false,
diff --git a/lib/public/util.php b/lib/public/util.php
index db07cbcfff3..6744c2d37bd 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -217,6 +217,7 @@ class Util {
*/
public static function getDefaultEmailAddress($user_part) {
$host_name = self::getServerHostName();
+ $host_name = \OC_Config::getValue('mail_domain', $host_name);
$defaultEmailAddress = $user_part.'@'.$host_name;
if (\OC_Mail::ValidateAddress($defaultEmailAddress)) {
diff --git a/tests/lib/util.php b/tests/lib/util.php
index b904c359807..1c9054264c9 100644
--- a/tests/lib/util.php
+++ b/tests/lib/util.php
@@ -47,4 +47,11 @@ class Test_Util extends PHPUnit_Framework_TestCase {
$email = \OCP\Util::getDefaultEmailAddress("no-reply");
$this->assertEquals('no-reply@localhost.localdomain', $email);
}
-} \ No newline at end of file
+
+ function testGetDefaultEmailAddressFromConfig() {
+ OC_Config::setValue('mail_domain', 'example.com');
+ $email = \OCP\Util::getDefaultEmailAddress("no-reply");
+ $this->assertEquals('no-reply@example.com', $email);
+ OC_Config::deleteKey('mail_domain');
+ }
+}