예제 #1
0
    public static void VerifySubscriber(object param)
    {
        object[] parameters        = (object[])param;
        List <Model_Subscriber> ms = (List <Model_Subscriber>)parameters[0];
        int Total = (int)parameters[1];

        //int Total = ms.Count;
        Codicode.EmailValidator Ev = new Codicode.EmailValidator();
        //We create our Mail Validator Object
        //Codicode.Emailvalidator Ev = new Codicode.Emailvalidator();
        //  Sender email (for smtp identification)
        Ev.Mail_From = "*****@*****.**";

        //  Sender email (for smtp identification)
        //bool Valid_Email = Ev.Check_MailBox(txtemail.Text.Trim());



        foreach (Model_Subscriber m in ms)
        {
            string err = Ev.Check_MailBox_Error(m.Email.Trim());
            string ret = "";
            if (err == "")
            {
                ret      = "mail ok";
                m.Detail = string.Empty;
            }
            else
            {
                ret      = err;
                m.Sbin   = false;
                m.Detail = err;
            }

            SubScriberController.UpdateVerify(m);
            Ev.Dispose();

            Lock.AcquireWriterLock(Timeout.Infinite);
            SubScriberVerifytController.TotalCompleted  += 1;
            SubScriberVerifytController.PercentCompleted =
                (decimal)SubScriberVerifytController.TotalCompleted * 100 / Total;
            Lock.ReleaseWriterLock();
        }

        Lock.AcquireWriterLock(Timeout.Infinite);
        SubScriberVerifytController.Onprocess = false;
        Lock.ReleaseWriterLock();
    }
예제 #2
0
    protected void btnCheck_Click(object sender, EventArgs e)
    {
        //const String APIURL = "https://api.email-validator.net/api/verify";
        //HttpClient client = new HttpClient();
        //String Email = txtemail.Text.Trim();
        //String APIKey = "ev-29d4b62536481db3907f7b39bdae7d5f";

        //var postData = new List<KeyValuePair<string, string>>();
        //postData.Add(new KeyValuePair<string, string>("EmailAddress", Email));
        //postData.Add(new KeyValuePair<string, string>("APIKey", APIKey));

        //HttpContent content = new FormUrlEncodedContent(postData);

        //HttpResponseMessage result = client.PostAsync(APIURL, content).Result;
        //string resultContent = result.Content.ReadAsStringAsync().Result;

        //APIResult res = new System.Web.Script.Serialization.JavaScriptSerializer().
        //                    Deserialize<APIResult>(resultContent);
        //string ret = string.Empty;
        //switch (res.status)
        //{
        //    // valid addresses have a {200, 207, 215} result code
        //    // result codes 114 and 118 need a retry
        //    case 200:
        //    case 207:
        //    case 215:
        //        ret = "address is valid";
        //        break;
        //    case 114:
        //        ret = "greylisting, wait 5min and retry";
        //        break;
        //    case 118:
        //        ret = "api rate limit, wait 5min and retry";
        //        break;
        //    default:
        //        ret = "address is invalid" + res.info + res.details;
        //        // res.info
        //        // res.details
        //        break;
        //}

        //lblret.Text = ret;

        Codicode.EmailValidator Ev = new Codicode.EmailValidator();
        //We create our Mail Validator Object
        //Codicode.Emailvalidator Ev = new Codicode.Emailvalidator();
        //  Sender email (for smtp identification)
        Ev.Mail_From = "*****@*****.**";

        //  Sender email (for smtp identification)
        //bool Valid_Email = Ev.Check_MailBox(txtemail.Text.Trim());


        string err = Ev.Check_MailBox_Error(txtemail.Text);
        string ret = "";

        if (err == "")
        {
            ret = "mail ok";
        }
        else
        {
            ret = err;
        }
        //lblret.Text = Valid_Email.ToString() + Ev.Check_MailBox_Error(txtemail.Text);
        lblret.Text = ret;
        Ev.Dispose();



        //string ret = string.Empty;

        //SmtpMail oMail = new SmtpMail("ss");
        //SmtpClient oSmtp = new SmtpClient();

        //// Set sender email address, please change it to yours
        //oMail.From = "*****@*****.**";

        //// Set recipient email address, please change it to yours
        //oMail.To = txtemail.Text.Trim();

        //// Do not set SMTP server address
        //SmtpServer oServer = new SmtpServer("");

        //try
        //{
        //   // Console.WriteLine("start to test email address ...");
        //    oSmtp.TestRecipients(oServer, oMail);
        //   // Console.WriteLine("email address was verified!");
        //    ret = "email address was verified!";
        //}
        //catch (Exception ep)
        //{
        //    //Console.WriteLine("failed to test email with the following error:");
        //    //Console.WriteLine(ep.Message);
        //    ret = "failed to test email with the following error:" + ep.Message;
        //}
    }