重设密码并发送新密码 [英] Reset password and to send the new password

查看:144
本文介绍了重设密码并发送新密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

For the netwo<code>rkcredential, any directive other than System.Net.Mail is required????

In the button click I did coding . but Iam getting an error ""The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated ""
coding is like this

protected void Button1_Click(object sender, EventArgs e)
    {
        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
        mail.To.Add(TextBox1.Text);
        mail.From = new System.Net.Mail.MailAddress("from");
        mail.Body = "Your new password is xxxx";
        mail.Subject = "New Password";
        System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("localhost");
        try
        {
            smtp.Send(mail);
            
            Response.Write("The mail has been sent to ");
            Response.Write(mail.To);
        }
        catch (System.Exception ex)
        {
            Response.Write(ex.Message);
        } 
    }

我已经创建了一个登录页面.在那有一个重置密码的选项.如何重设密码.我需要进行编码,因为当用户单击重置"按钮时,应该将新密码发送到他的邮件中.我怎样才能做到这一点.从我必须开始的地方.请帮助.

I have created one login page. In that there is an option for reset password. How can I reset the password. I need to do the codeing as, when the user click the reset button a new password should be send to his mail. How can I do this. From where I have to start. pls help.

推荐答案

首先,您需要使用注册时用户回答的任何安全问题来验证使用身份验证,然后生成一些随机代码
使用该代码更新数据库,然后将邮件发送给用户.

要发送电子邮件,请检查此.
如何通过asp.net发送电子邮件 [ ^ ]
First of all you need to verify the use authentication using any security question answered by user at registration time and then generate some random code
update database with that code and then send mail to the user.

to send email check this.
How to send email through asp.net[^]


,您还需要更新数据库中的密码,并发送一封指定新密码的邮件.
发送邮件使用
you should need to update password in your database also and send a mail that specifies new password.
to send mail use
public static Boolean SendingMail(string From, string To, string Subject, string Body)
   {

           try
           {
               MailMessage m = new MailMessage("uid", To);
               m.Subject = Subject;
               m.Body = Body;
               m.IsBodyHtml = true;
               m.From = new MailAddress(From);

               m.To.Add(new MailAddress(To));
               SmtpClient smtp = new SmtpClient();
               smtp.Host = "mail.google.com";

               NetworkCredential authinfo = new NetworkCredential("uid", "password");
               smtp.UseDefaultCredentials = false;
               smtp.Credentials = authinfo;
               smtp.Send(m);
               return true;




           }
           catch (Exception ex)
           {
               return false;
           }
       }


首先,您需要使用用户在注册时回答的任何安全问题来验证使用身份验证,然后重置其密码



您可以直接将新密码的电子邮件发送给他/她在注册时给出的电子邮件ID.

要重置密码,您只需向您的数据库触发UPDATE查询,并根据符合以上任何条件的用户条件设置新密码

对于重置密码",您可以使用用户的生日将其重置,也可以使用编码生成随机单词来重置密码.



对于发送电子邮件,请参阅此链接,它将对您有所帮助..
如何从中发送电子邮件您的ASP.NET Web应用程序...? [
First of all you need to verify the use authentication using any security question answered by user at registration time and then reset his/her password

OR

You can directly send a email of new password to his/her mail id given on registration time.

For resetting password you can just fire a UPDATE query to you db and set new password on the basis of the user criteria matched on above any condition

For Reset Password, you can reset it with user''s birth date or you can also genrate random word using coding to reset the password.



For Sending Email Please see this link it will help full to you..
How to send A E-Mail From Your ASP.NET web Application...?[^]


这篇关于重设密码并发送新密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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