private void btCheckSettings_Click(object sender, EventArgs e) { if (tbPassword.Text != string.Empty) { ViewState["Pop3Box_Password"] = tbPassword.Text; } Pop3SecureConnectionType sct = Pop3SecureConnectionType.None; switch (rblSecureConnection.SelectedValue) { case "Never": sct = Pop3SecureConnectionType.None; break; case "SSL": sct = Pop3SecureConnectionType.Ssl; break; case "TLS": sct = Pop3SecureConnectionType.Tls; break; } Pop3SettingsResult sok = EMailRouterPop3Box.CheckSettings(tbServer.Text.Trim(), int.Parse(tbPort.Text.Trim()), tbLogin.Text.Trim(), tbPassword.Text != string.Empty ? tbPassword.Text : ViewState["Pop3Box_Password"].ToString(), sct); lbSettingsValid.Visible = true; if (sok == Pop3SettingsResult.AllOk) { lbSettingsValid.ForeColor = Color.Blue; lbSettingsValid.Text = LocRM.GetString("tOK"); rfvPassword.Enabled = rfvConfirmPassword.Enabled = cvConfirmPassword.Enabled = false; } else { lbSettingsValid.ForeColor = Color.Red; lbSettingsValid.Text = LocRM.GetString("tError"); rfvPassword.Enabled = rfvConfirmPassword.Enabled = cvConfirmPassword.Enabled = true; if (sok == Pop3SettingsResult.None) { rfvServer.IsValid = rfvPort.IsValid = false; } else if (sok == Pop3SettingsResult.ServerName) { rfvLogin.IsValid = false; } else if (sok == (Pop3SettingsResult.ServerName | Pop3SettingsResult.Pop3User)) { rfvPassword.IsValid = false; } } }
/// <summary> /// Creates the external. /// </summary> /// <param name="Server">The server.</param> /// <param name="Port">The port.</param> /// <param name="Login">The login.</param> /// <param name="Password">The password.</param> /// <returns></returns> public static int CreateExternal(string Name, string EMailAddress, string Server, int Port, string Login, string Password, Pop3SecureConnectionType SecureConnectionType) { if (!CanModify()) { throw new AccessDeniedException(); } EMailRouterPop3BoxRow newRow = new EMailRouterPop3BoxRow(); newRow.IsInternal = false; newRow.Name = Name; newRow.InternalEMailAddress = EMailAddress; newRow.Server = Server; newRow.Port = Port; newRow.Login = Login; newRow.Pass = Password; newRow.UseSecureConnection = (int)SecureConnectionType; newRow.Update(); return(newRow.PrimaryKeyId); }
public static Pop3SettingsResult CheckSettings(string Server, int Port, string User, string Password, Pop3SecureConnectionType SecureConnectionType) { string strEMailHost = Server; int iEMailPort = Port; string strEMailUser = User; string strEMailPassword = Password; Pop3SettingsResult retVal = Pop3SettingsResult.None; try { //IPHostEntry hostInfo = Dns.GetHostEntry(strEMailHost); IPAddress[] addresses = Dns.GetHostAddresses(strEMailHost); if (addresses.Length > 0) { IPEndPoint pop3ServerEndPoint = new IPEndPoint(addresses[0], iEMailPort); Pop3Connection pop3Connection = new Pop3Connection(); if (SecureConnectionType == Pop3SecureConnectionType.Ssl) { pop3Connection.OpenSsl(pop3ServerEndPoint, Server); } else { pop3Connection.Open(pop3ServerEndPoint); } if (SecureConnectionType == Pop3SecureConnectionType.Tls) { pop3Connection.Stls(Server); } retVal |= Pop3SettingsResult.ServerName; try { pop3Connection.User(strEMailUser); retVal |= Pop3SettingsResult.Pop3User; pop3Connection.Pass(strEMailPassword); retVal |= Pop3SettingsResult.Pop3Password; Pop3Stat stat = pop3Connection.Stat(); } finally { pop3Connection.Quit(); } } } catch (Exception ex) { string strErrMsg = ex.Message; } return(retVal); }
private void imbSave_ServerClick(object sender, EventArgs e) { if (BoxId > 0) { EMailRouterPop3Box box = EMailRouterPop3Box.Load(BoxId); if (box != null) { box.Name = txtName.Text; box.Server = tbServer.Text.Trim(); box.Port = int.Parse(tbPort.Text.Trim()); box.Login = tbLogin.Text; box.Pass = tbPassword.Text != string.Empty ? tbPassword.Text : ViewState["Pop3Box_Password"].ToString(); box.EMailAddress = tbInternalEmail.Text; switch (rblSecureConnection.SelectedValue) { case "Never": box.SecureConnectionType = Pop3SecureConnectionType.None; break; case "SSL": box.SecureConnectionType = Pop3SecureConnectionType.Ssl; break; case "TLS": box.SecureConnectionType = Pop3SecureConnectionType.Tls; break; } EMailRouterPop3Box.Update(box); if (int.Parse(ddSmtpBoxes.SelectedValue) > 0) { OutgoingEmailServiceConfig.AssignWithSmtpBox(OutgoingEmailServiceType.HelpDeskEmailBox, BoxId, int.Parse(ddSmtpBoxes.SelectedValue)); } else { OutgoingEmailServiceConfig.AssignWithDefaultSmtpBox(OutgoingEmailServiceType.HelpDeskEmailBox, BoxId); } } } else { Pop3SecureConnectionType sct = Pop3SecureConnectionType.None; switch (rblSecureConnection.SelectedValue) { case "Never": sct = Pop3SecureConnectionType.None; break; case "SSL": sct = Pop3SecureConnectionType.Ssl; break; case "TLS": sct = Pop3SecureConnectionType.Tls; break; } if (IsInternal) { int boxId = EMailRouterPop3Box.CreateInternal(txtName.Text, tbInternalEmail.Text.Trim(), tbServer.Text.Trim(), int.Parse(tbPort.Text.Trim()), tbLogin.Text, tbPassword.Text != string.Empty ? tbPassword.Text : ViewState["Pop3Box_Password"].ToString(), sct); if (int.Parse(ddSmtpBoxes.SelectedValue) > 0) { OutgoingEmailServiceConfig.AssignWithSmtpBox(OutgoingEmailServiceType.HelpDeskEmailBox, boxId, int.Parse(ddSmtpBoxes.SelectedValue)); } else { OutgoingEmailServiceConfig.AssignWithDefaultSmtpBox(OutgoingEmailServiceType.HelpDeskEmailBox, boxId); } } else { int boxId = EMailRouterPop3Box.CreateExternal(txtName.Text, tbInternalEmail.Text, tbServer.Text.Trim(), int.Parse(tbPort.Text.Trim()), tbLogin.Text, tbPassword.Text != string.Empty ? tbPassword.Text : ViewState["Pop3Box_Password"].ToString(), sct); if (int.Parse(ddSmtpBoxes.SelectedValue) > 0) { OutgoingEmailServiceConfig.AssignWithSmtpBox(OutgoingEmailServiceType.HelpDeskEmailBox, boxId, int.Parse(ddSmtpBoxes.SelectedValue)); } else { OutgoingEmailServiceConfig.AssignWithDefaultSmtpBox(OutgoingEmailServiceType.HelpDeskEmailBox, boxId); } } } Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "try {window.opener.location.href=window.opener.location.href;}" + "catch (e){} window.close();", true); }
/// <summary> /// Creates the internal. /// </summary> /// <param name="InternalEMailAddress">The internal E mail address.</param> /// <param name="Server">The server.</param> /// <param name="Port">The port.</param> /// <param name="Login">The login.</param> /// <param name="Password">The password.</param> public static int CreateInternal(string Name, string EMailAddress, string Server, int Port, string Login, string Password, Pop3SecureConnectionType SecureConnectionType) { if(!CanModify()) throw new AccessDeniedException(); EMailRouterPop3BoxRow newRow = new EMailRouterPop3BoxRow(); newRow.IsInternal = true; newRow.Name = Name; newRow.InternalEMailAddress = EMailAddress; newRow.Server = Server; newRow.Port = Port; newRow.Login = Login; newRow.Pass = Password; newRow.UseSecureConnection = (int)SecureConnectionType; newRow.Update(); return newRow.PrimaryKeyId; }
public static Pop3SettingsResult CheckSettings(string Server, int Port, string User, string Password, Pop3SecureConnectionType SecureConnectionType) { string strEMailHost = Server; int iEMailPort = Port; string strEMailUser = User; string strEMailPassword = Password; Pop3SettingsResult retVal = Pop3SettingsResult.None; try { //IPHostEntry hostInfo = Dns.GetHostEntry(strEMailHost); IPAddress[] addresses = Dns.GetHostAddresses(strEMailHost); if (addresses.Length > 0) { IPEndPoint pop3ServerEndPoint = new IPEndPoint(addresses[0], iEMailPort); Pop3Connection pop3Connection = new Pop3Connection(); if (SecureConnectionType == Pop3SecureConnectionType.Ssl) { pop3Connection.OpenSsl(pop3ServerEndPoint, Server); } else { pop3Connection.Open(pop3ServerEndPoint); } if (SecureConnectionType == Pop3SecureConnectionType.Tls) { pop3Connection.Stls(Server); } retVal |= Pop3SettingsResult.ServerName; try { pop3Connection.User(strEMailUser); retVal |= Pop3SettingsResult.Pop3User; pop3Connection.Pass(strEMailPassword); retVal |= Pop3SettingsResult.Pop3Password; Pop3Stat stat = pop3Connection.Stat(); } finally { pop3Connection.Quit(); } } } catch (Exception ex) { string strErrMsg = ex.Message; } return retVal; }