diff --git a/interface/lib/classes/remote.d/mail.inc.php b/interface/lib/classes/remote.d/mail.inc.php
index dfbad2759581518228cdd5f3805c6421ace0e652..d5d892f155aa1fb79a3d71da10c9f30f09831c41 100644
--- a/interface/lib/classes/remote.d/mail.inc.php
+++ b/interface/lib/classes/remote.d/mail.inc.php
@@ -223,7 +223,7 @@ class remoting_mail extends remoting {
 			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
 			return false;
 		}
-		
+
 		// Email addresses must always be lower case
 		$params['email'] = strtolower($params['email']);
 
@@ -331,17 +331,17 @@ class remoting_mail extends remoting {
 		// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this);
 		return $affected_rows;
 	}
-	
+
 	// Mail backup list function by Dominik Müller, info@profi-webdesign.net
 	public function mail_user_backup_list($session_id, $primary_id = null)
 	{
 		global $app;
-	
+
 		if(!$this->checkPerm($session_id, 'mail_user_backup')) {
 			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
 			return false;
 		}
-	
+
 		$params = array();
 		if ($site_id != null) {
 			$params[] = $site_id;
@@ -350,47 +350,47 @@ class remoting_mail extends remoting {
 		else {
 			$sql  = "SELECT * FROM mail_backup";
 		}
-	
+
 		$result = $app->db->queryAllRecords($sql, true, $params);
 		return $result;
 	}
-	
+
 	// Mail backup restore/download functions by Dominik Müller, info@profi-webdesign.net
 	public function mail_user_backup($session_id, $primary_id, $action_type)
 	{
 		global $app;
-	
+
 		if(!$this->checkPerm($session_id, 'mail_user_backup')) {
 			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
 			return false;
 		}
-	
+
 		//*Set variables
 		$backup_record  =       $app->db->queryOneRecord("SELECT * FROM `mail_backup` WHERE `backup_id`=?", $primary_id);
 		$server_id      =       $backup_record['server_id'];
-	
+
 		//*Set default action state
 		$action_state   =       "pending";
 		$tstamp         =       time();
-	
+
 		//* Basic validation of variables
 		if ($server_id <= 0) {
 			throw new SoapFault('invalid_backup_id', "Invalid or non existant backup_id $primary_id");
 			return false;
 		}
-	
+
 		if (/*$action_type != 'backup_download_mail' and*/ $action_type != 'backup_restore_mail' and $action_type != 'backup_delete_mail') {
 			throw new SoapFault('invalid_action', "Invalid action_type $action_type");
 			return false;
 		}
-	
+
 		//* Validate instance
 		$instance_record        =       $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`=? and `action_type`=? and `action_state`='pending'", $primary_id, $action_type);
 		if ($instance_record['action_id'] >= 1) {
 			throw new SoapFault('duplicate_action', "There is already a pending $action_type action");
 			return false;
 		}
-	
+
 		//* Save the record
 		if ($app->db->query("INSERT INTO `sys_remoteaction` SET `server_id` = ?, `tstamp` = ?, `action_type` = ?, `action_param` = ?, `action_state` = ?", $server_id, $tstamp, $action_type, $primary_id, $action_state)) {
 			return true;
@@ -666,7 +666,19 @@ class remoting_mail extends remoting {
 		$affected_rows = $this->deleteQuery('../mail/form/mail_relay_recipient.tform.php', $primary_id);
 		return $affected_rows;
 	}
-	
+
+    //* add relay domain
+    public function mail_relay_domain_add($session_id, $client_id, $params)
+	{
+    	if(!$this->checkPerm($session_id, 'mail_relay_add'))
+		{
+            throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
+            return false;
+    	}
+    	$affected_rows = $this->insertQuery('../mail/form/mail_relay_domain.tform.php', $client_id, $params);
+    	return $affected_rows;
+	}
+
 	//* Get spamfilter whitelist details
 	public function mail_spamfilter_whitelist_get($session_id, $primary_id)
 	{
@@ -1117,12 +1129,12 @@ class remoting_mail extends remoting {
 	{
 		global $app;
 		$app->uses('quota_lib');
-		
+
 		if(!$this->checkPerm($session_id, 'mailquota_get_by_user')) {
 			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
 			return false;
 		}
-		
+
 		return $app->quota_lib->get_mailquota_data($client_id, false);
 	}
 
diff --git a/interface/web/mail/lib/remote.conf.php b/interface/web/mail/lib/remote.conf.php
index 3060a8b4cc7be87c3e15f75f015822eac8bec2a4..faf1d5aa29d6197a3d9a89f3c742c6a507ccd4a1 100644
--- a/interface/web/mail/lib/remote.conf.php
+++ b/interface/web/mail/lib/remote.conf.php
@@ -9,6 +9,7 @@ $function_list['mail_forward_get,mail_forward_add,mail_forward_update,mail_forwa
 $function_list['mail_catchall_get,mail_catchall_add,mail_catchall_update,mail_catchall_delete'] = 'Mail catchall functions';
 $function_list['mail_transport_get,mail_transport_add,mail_transport_update,mail_transport_delete'] = 'Mail transport functions';
 $function_list['mail_relay_get,mail_relay_add,mail_relay_update,mail_relay_delete'] = 'Mail relay functions';
+$function_list['mail_relay_domain_add'] = 'Mail relay domain functions';
 $function_list['mail_whitelist_get,mail_whitelist_add,mail_whitelist_update,mail_whitelist_delete'] = 'Mail whitelist functions';
 $function_list['mail_blacklist_get,mail_blacklist_add,mail_blacklist_update,mail_blacklist_delete'] = 'Mail blacklist functions';
 $function_list['mail_spamfilter_user_get,mail_spamfilter_user_add,mail_spamfilter_user_update,mail_spamfilter_user_delete'] = 'Mail spamfilter user functions';