密码重置链接在ASP.Net中不起作用

时间:2018-09-06 07:10:59

标签: gmail smtpclient reset-password

SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:5.5.1需要身份验证

我在运行此代码时遇到问题,然后发生错误“ SMTP服务器需要安全连接或客户端未通过身份验证。服务器响应为:5.5.1需要身份验证。”

我的代码是:

String ToEmailAddress = dt.Rows[0][4].ToString();
            String UserName = dt.Rows[0][1].ToString();
            String EmailBody = "Hi!" + UserName + ",<br /><br />Click the Link to Reset your Password <br />http://localhost:50982/ForgotPassword.aspx?Uid=" + myGUID;
            MailMessage PassRecMail = new MailMessage("youremail@gmail.com", ToEmailAddress);
            PassRecMail.Body = EmailBody;
            PassRecMail.IsBodyHtml = true;
            PassRecMail.Subject = "Reset Password";

            SmtpClient SMTP = new SmtpClient("smtp.gmail.com", 587);
            SMTP.Credentials = new NetworkCredential()

            {
                UserName = "youremail@gmail.com",
                Password = "yourPasswordabc"
            };
            SMTP.EnableSsl = true;
            SMTP.Send(PassRecMail);

            lblPassRec.Text = "Check your Email to Reset Password";
            lblPassRec.ForeColor = Color.Green;

0 个答案:

没有答案