示例#1
0
        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);
        }
示例#2
0
        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;
                }
            }
        }
示例#3
0
        protected void btnCheck_Click(object sender, System.EventArgs e)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "<script>EnableDisable();</script>");
            string sServer = txtServer.Value;
            int    iPort   = 0;

            try
            {
                iPort = int.Parse(txtPort.Value);
            }
            catch
            {
                lblCheck.Visible   = true;
                lblCheck.ForeColor = Color.Red;
                lblCheck.Text      = LocRM.GetString("tError") + "&nbsp;";
                return;
            }
            string sUser = txtUser.Value;
            string sPass = txtPass.Value;

            if (sPass.Length <= 0)
            {
                sPass = Password;
            }
            else
            {
                ViewState["_Pass"] = txtPass.Value;
            }

            //TEST Addon (OlegO):
            //Incident.CreateFromEMail();

            Pop3SettingsResult _sok = EMailRouterPop3Box.CheckSettings(sServer, iPort, sUser, sPass, Pop3SecureConnectionType.None);

            if (_sok == Pop3SettingsResult.AllOk)
            {
                lblCheck.Visible   = true;
                lblCheck.ForeColor = Color.Blue;
                lblCheck.Text      = LocRM.GetString("tOK") + "&nbsp;";
            }
            else if (_sok == Pop3SettingsResult.None)
            {
                lblCheck.Visible    = true;
                lblCheck.ForeColor  = Color.Red;
                lblCheck.Text       = LocRM.GetString("tError") + "&nbsp;";
                lblServerError.Text = "*";
                lblPortError.Text   = "*";
            }
            else if (_sok == Pop3SettingsResult.ServerName)
            {
                lblCheck.Visible   = true;
                lblCheck.ForeColor = Color.Red;
                lblCheck.Text      = LocRM.GetString("tError") + "&nbsp;";
                lblUserError.Text  = "*";
            }
            else if (_sok == (Pop3SettingsResult.ServerName | Pop3SettingsResult.Pop3User))
            {
                lblCheck.Visible   = true;
                lblCheck.ForeColor = Color.Red;
                lblCheck.Text      = LocRM.GetString("tError") + "&nbsp;";
                lblUserError.Text  = "*";
                lblPassError.Text  = "*";
            }
            foreach (ListItem liItem in ddFolder.Items)
            {
                if (liItem.Value.IndexOf("*") >= 0)
                {
                    liItem.Attributes.Add("style", "COLOR: gray;");
                }
            }
        }