summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRandolph Carter <RandolphCarter@fantasymail.de>2012-12-19 01:09:14 +0100
committerRandolph Carter <RandolphCarter@fantasymail.de>2012-12-19 13:05:49 +0100
commit1265bfa9b031c5da82e4c4df9fd33e8573a47546 (patch)
tree62adeebb607bb7be78f82a2dd666798319b91ea2 /lib
parenta5a25eb2a81dc2bc6fe4be8fe6766d7a82989516 (diff)
downloadnextcloud-server-1265bfa9b031c5da82e4c4df9fd33e8573a47546.tar.gz
nextcloud-server-1265bfa9b031c5da82e4c4df9fd33e8573a47546.zip
backport of fixing default email sender address
Diffstat (limited to 'lib')
-rw-r--r--lib/public/util.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/public/util.php b/lib/public/util.php
index 38da7e82171..51b6d12b628 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -173,6 +173,42 @@ class Util {
}
/**
+ * @brief returns the server hostname
+ * @returns the server hostname
+ *
+ * Returns the server host name without an eventual port number
+ */
+ public static function getServerHostName() {
+ $host_name = self::getServerHost();
+ // strip away port number (if existing)
+ $colon_pos = strpos($host_name, ':');
+ if ($colon_pos != FALSE) {
+ $host_name = substr($host_name, 0, $colon_pos);
+ }
+ return $host_name;
+ }
+
+ /**
+ * @brief Returns the default email address
+ * @param $user_part the user part of the address
+ * @returns the default email address
+ *
+ * Assembles a default email address (using the server hostname
+ * and the given user part, and returns it
+ * Example: when given lostpassword-noreply as $user_part param,
+ * and is currently accessed via http(s)://example.com/,
+ * it would return 'lostpassword-noreply@example.com'
+ */
+ public static function getDefaultEmailAddress($user_part) {
+ $host_name = self::getServerHostName();
+ // handle localhost installations
+ if ($server_host === 'localhost') {
+ $server_host = "example.com";
+ }
+ return $user_part.'@'.$host_name;
+ }
+
+ /**
* @brief Returns the server protocol
* @returns the server protocol
*