Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void BtnConnect_Click(object sender, EventArgs e)
- {
- string cm_status = "notstarted";
- bool success = false;
- if (CbType.Text == "IMAP")
- {
- using (Chilkat.Imap imap = new Chilkat.Imap())
- {
- success = imap.UnlockComponent("Anything for 30-day trial");
- if (success == true)
- {
- imap.KeepSessionLog = true;
- imap.ConnectTimeout = 30;
- imap.ReadTimeout = 30;
- imap.Port = Convert.ToInt32(NudPort.Value);
- imap.Ssl = Convert.ToBoolean(CbSSL.Text);
- success = imap.Connect(TbServer.Text);
- if (success == true)
- {
- success = imap.Login(TbMail.Text, TbPassword.Text);
- if (success == true)
- {
- cm_status = "good_mail";
- }
- else
- {
- if (TbServer.Text == "imap.gmail.com")
- {
- if (imap.SessionLog.Contains("Please log in via your web browser") || imap.SessionLog.Contains("Application-specific password required"))
- {
- cm_status = "blocked_mail";
- }
- else
- {
- cm_status = "bad_mail";
- }
- }
- else if (TbServer.Text == "imap.mail.ru")
- {
- if (imap.SessionLog.Contains("Please verify your account"))
- {
- cm_status = "blocked_mail";
- }
- else
- {
- cm_status = "bad_mail";
- }
- }
- else
- {
- cm_status = "bad_mail";
- }
- }
- imap.Disconnect();
- }
- else
- {
- if (imap.LastErrorText.Contains("Failed to connect"))
- {
- cm_status = "bad_proxy";
- }
- else
- {
- cm_status = "error";
- }
- }
- Console.WriteLine(imap.SessionLog);
- }
- else
- {
- cm_status = "error";
- }
- Console.WriteLine(imap.LastErrorText);
- }
- }
- else if (CbType.Text == "POP3")
- {
- using (Chilkat.MailMan pop3 = new Chilkat.MailMan())
- {
- success = pop3.UnlockComponent("Anything for 30-day trial");
- if (success == true)
- {
- pop3.ConnectTimeout = 30;
- pop3.ReadTimeout = 30;
- pop3.MailHost = TbServer.Text;
- pop3.MailPort = Convert.ToInt32(NudPort.Value);
- pop3.PopSsl = Convert.ToBoolean(CbSSL.Text);
- pop3.PopUsername = TbMail.Text;
- pop3.PopPassword = TbPassword.Text;
- success = pop3.Pop3Connect();
- if (success == true)
- {
- success = pop3.Pop3Authenticate();
- if (success == true)
- {
- cm_status = "good_mail";
- }
- else
- {
- if (TbServer.Text == "pop.gmail.com")
- {
- if (pop3.Pop3SessionLog.Contains("Web login required") || pop3.Pop3SessionLog.Contains("Application-specific password required"))
- {
- cm_status = "blocked_mail";
- }
- else
- {
- cm_status = "bad_mail";
- }
- }
- else
- {
- cm_status = "bad_mail";
- }
- }
- pop3.Pop3EndSession();
- }
- else
- {
- if (pop3.LastErrorText.Contains("Failed to connect"))
- {
- cm_status = "bad_proxy";
- }
- else
- {
- cm_status = "error";
- }
- }
- Console.WriteLine(pop3.Pop3SessionLog);
- }
- else
- {
- cm_status = "error";
- }
- Console.WriteLine(pop3.LastErrorText);
- }
- }
- Console.WriteLine(cm_status);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement