首页 新闻 会员 周边 捐助

SMTP 服务器要求安全连接或客户端未通过身份验证。 服务器响应为: 5.7.0 Must issue a STARTTLS command fi

0
悬赏园豆:20 [已关闭问题] 关闭于 2012-09-21 17:57

protected void Cmd_Reg_Click(object sender, EventArgs e)
         {
               Random random = new Random();
                     string checkCode = "";
                     for (int i = 0; i <= 4; i++)
                     {
                         int num = random.Next(1, 10);
                         checkCode += num.ToString();
                     }
                     string validataCode = FormsAuthentication.HashPasswordForStoringInConfigFile(checkCode, "md5");
              SqlConnection conn = new SqlConnection(str);
             conn.Open();
             string sql = "insert into Email(UserId,UserPas,mail,AddDate,ValidataCode,UserState) values(@UserId,@UserPas,@mail,@AddDate,@ValidataCode,@UserState)";
             SqlCommand cmd = new SqlCommand(sql,conn);
             SqlParameter[] param = { 
                                    new SqlParameter("@UserId",Txt_Name.Text),
                                    new  SqlParameter("@UserPas",Txt_Pwd.Text),
                                    new  SqlParameter("@mail",Txt_Email.Text),
                                    new  SqlParameter("@AddDate",DateTime.Now),
                                    new  SqlParameter("@ValidataCode", validataCode),
                                     new  SqlParameter("@UserState",false),
                                    };
             cmd.Parameters.AddRange(param);
             int result =  cmd.ExecuteNonQuery();
             conn.Close();
             if (result > 0)
             {
                 ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", "<script>alert('ok')</script>");
                 string strSmtpServer = "smtp.gmail.com";
                 string strFrom ="358730096@qq.com";
                 string strFromPass = "123456";
                 string strto = Txt_Email.Text;
                 string strSubject = "账号激活";
               StringBuilder strBody = new StringBuilder();
                 strBody.Append("点击下面链接激活账号,48小时生效,否则就要重新注册账号,链接只能使用一次,请尽快激活!</br>");
                 strBody.Append("<a href='http://localhost:2493/web/Operate.aspx?userName=" + Txt_Name.Text + "&validateCode=" + validataCode + "'>点击这里</a></br>");
                 strBody.Append("如未能激活请点击下面链接:<a href='http://localhost:2493/web/Operate.aspx?userName=" + Txt_Name.Text + "&validateCode=" + validataCode + "'>http://localhost:2493/web/Operate.aspx?userName=" + Txt_Name.Text + "&validateCode=" + validataCode + "</a></br>");
                 SendSMTPEMail(strSmtpServer, strFrom, strFromPass, strto, strSubject, strBody.ToString());
             }
             else
             {
                 ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", "<script>alert('Nok')</script>");
             }    
         }
         //发送邮件
  public void SendSMTPEMail(string strSmtpServer, string strFrom, string strFromPass, string strto, string strSubject, string strBody)
         {      
           MailMessage message = new MailMessage(strFrom, strto, strSubject, strBody);
             message.BodyEncoding = System.Text.Encoding.UTF8;
             message.IsBodyHtml = true;
             message.Priority = MailPriority.High;
            SmtpClient client = new SmtpClient(strSmtpServer);
             client.UseDefaultCredentials = true;
             client.Credentials =
             new  NetworkCredential(strFrom, strFromPass);
             client.DeliveryMethod = SmtpDeliveryMethod.Network;
             client.EnableSsl = false;
             client.Send(message);
         }

运行时报错:SMTP 服务器要求安全连接或客户端未通过身份验证。 服务器响应为: 5.7.0 Must issue a STARTTLS command first. te6sm1553294pbc.29   这是什么错误??求助!!!!

柒喵的主页 柒喵 | 菜鸟二级 | 园豆:208
提问于:2012-09-17 16:40
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册