通过电子邮件忘记密码在Asp.Net中的页面代码 [英] Forgot Password By Email Page Code In Asp.Net

查看:78
本文介绍了通过电子邮件忘记密码在Asp.Net中的页面代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证。了解更多信息



Asp.code



i got error The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at

Asp.code

<div>
<table cellspacing="2" cellpadding="2" border="0" class="auto-style18">
<tr><td class="auto-style20"></td><td class="auto-style20"><b>Forgot Password</b></td></tr>
<tr><td><b>Enter Your Email:</b></td><td><asp:TextBox ID="txtEmail" runat="server" /></td></tr>
<tr><td class="auto-style19"></td><td class="auto-style19"><asp:button ID="btnSubmit" Text="Submit"  runat="server" CssClass="Button" OnClick="btnSubmit_Click"/></td></tr>
<tr><td colspan="2" style=" color:red"><asp:Label ID="lbltxt" runat="server"/></td></tr>
</table>
</div>









c#code





c# code

SqlConnection con = new SqlConnection("Data Source=***_06;Initial Catalog=****;User ID=***;Password=****");            
                con.Open();
                SqlCommand cmd = new SqlCommand("select username,password from getezee Where mail=@mails",con);
                cmd.Parameters.AddWithValue("@mails", txtEmail.Text.Trim());
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                ds = new DataSet();
                da.Fill(ds);
                con.Close();
            
            if (ds.Tables[0].Rows.Count > 0)
            {
                MailMessage Msg = new MailMessage();   // Sender e-mail address.               
                Msg.From = new MailAddress("prakash@gmail.com");   // Recipient e-mail address.             
                Msg.To.Add(txtEmail.Text.ToString());
                Msg.Subject = "Your Password Details";
                Msg.Body = "Hi, <br />Please check your Login Detailss<br /><br />Your Username: " + ds.Tables[0].Rows[0]["username"] + "<br /><br />Your Password: " + ds.Tables[0].Rows[0]["password"] + "<br /><br />";
                Msg.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();    
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;             
                smtp.Credentials = new NetworkCredential("prakash@gmail.com", "prakash");
                smtp.EnableSsl = true;
                smtp.Send(Msg);             
                lbltxt.Text = "Your Password Details Sent to your mail";              
                txtEmail.Text = "";

            }
            else
            {
                lbltxt.Text = "The Email you entered not exists.";
            }

推荐答案

尝试设置UseDefaultCredentials = false



Try setting UseDefaultCredentials=false

smtp.UseDefaultCredentials = false;


删除此行,

smtp。 EnableSsl = true;



好​​的,试试这个:



Remove this line,
smtp.EnableSsl = true;

Okay, try this:

string name ="name";
                    string password = "password";
                    string email_id = "email";

                    MailMessage mail = new MailMessage();
                    mail.From = new MailAddress("blah@gmail.com");
                    mail.To.Add(email);

                    mail.Subject = "Password Recovery ";
                    mail.Body = "Name : " + name +
                                "<br />Password : " + password +
                                "<br />Email : " + email_id;
                    mail.IsBodyHtml = true;

                    SmtpClient client = new SmtpClient();
                    client.Host = "smtp.gmail.com";
                    client.Port = 587;
                    client.EnableSsl = true;
                    client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                    client.Credentials = new System.Net.NetworkCredential("blah@gmail.com", "8888888888");
                    client.Timeout = 2000000;
                    client.Send(mail);





-KR



-KR


这篇关于通过电子邮件忘记密码在Asp.Net中的页面代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆