private static void Save(string connectionString, string ip, string token, string host)
        {
            var mailServer = new MailServerInfo
            {
                DbConnection = connectionString,
                Api          = new MailServerApiInfo
                {
                    Port     = MailServiceHelper.DefaultPort,
                    Protocol = MailServiceHelper.DefaultProtocol,
                    Server   = ip,
                    Token    = token,
                    Version  = MailServiceHelper.DefaultVersion
                }
            };

            MailServiceHelper.UpdateDataFromInternalDatabase(host, mailServer);

            MessageService.Send(HttpContext.Current.Request, MessageAction.MailServiceSettingsUpdated);
        }
        public object Save(string ip, string user, string password, string token, string host)
        {
            try
            {
                IPAddress ipAddress;

                if (string.IsNullOrEmpty(ip) || !IPAddress.TryParse(ip, out ipAddress))
                {
                    throw new ArgumentException("ip");
                }

                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentException("user");
                }

                if (string.IsNullOrEmpty(password))
                {
                    throw new ArgumentException("password");
                }

                if (string.IsNullOrEmpty(token))
                {
                    throw new ArgumentException("token");
                }

                if (string.IsNullOrEmpty(host))
                {
                    throw new ArgumentException("host");
                }

                var connectionString = string.Format(ConnectionStringFormat, ip, DefaultDatabase, user, password);

                var mailServer = new MailServerInfo
                {
                    DbConnection = connectionString,
                    Api          = new MailServerApiInfo
                    {
                        Port     = DefaultPort,
                        Protocol = DefaultProtocol,
                        Server   = ip,
                        Token    = token,
                        Version  = DefaultVersion
                    }
                };

                MailServiceHelper.UpdateDataFromInternalDatabase(host, mailServer);

                ClearCache();

                return(new
                {
                    Status = "success",
                    Message = Resources.Resource.MailServiceSaveSuccessMsg
                });
            }
            catch (Exception exception)
            {
                LogManager.GetLogger("ASC.Web.MailService").Error(exception);

                return(new
                {
                    Status = "error",
                    Message = exception.Message.HtmlEncode()
                });
            }
        }