diff --git a/config/config.sample.php b/config/config.sample.php
index ec61ceefd6cd27167c5ba1a472f68caac5c4d1e9..995a02f6d945341848c74948727164ab8dd691aa 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 db07cbcfff3911a1e93852cfcaba484c6b455076..6744c2d37bdde2535f20a7646d8a307a2ccd1a17 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 b904c35980775f65822e676a761160cd81649737..1c9054264c9c7e1ac34d212f3aea7e8d8683f6f0 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');
+	}
+}