-2

I have an asp.net site which somewhere requires new users to do registration. In the registration form, their name, password & email-id are asked. Now if the user forgets his password, I want to mail him his password on the email-id he has given.

Now how to mail him ??

Any link or any tips would be very useful.

Thanks in advance.

Abhinav
  • 5
  • 6
  • 1
    `"I want to mail him his password"` - ***NEVER DO THIS***. This means that you're storing users' passwords in plain text, or at best a reversible encryption. This is ***grossly irresponsible*** to your users. Passwords should be stored by means of a 1-way hash. You should ***never*** be able to read a user's password. If the user forgets his password, provide a form where he can reset it. But ***do not*** store the password in a readable form and share it back to the user. – David May 27 '14 at 11:52
  • @David.. Thanks.. Its such a useful info. – Abhinav Jun 06 '14 at 09:08

1 Answers1

0
SmtpClient smtpClient = new SmtpClient("mail.MyWebsiteDomainName.com", 25);

smtpClient.Credentials = new System.Net.NetworkCredential("info@MyWebsiteDomainName.com", "myIDPassword");
smtpClient.UseDefaultCredentials = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
MailMessage mail = new MailMessage();

//Setting From , To and CC
mail.From = new MailAddress("info@MyWebsiteDomainName", "MyWeb Site");
mail.To.Add(new MailAddress("info@MyWebsiteDomainName"));
mail.CC.Add(new MailAddress("MyEmailID@gmail.com"));

smtpClient.Send(mail);
codebased
  • 6,945
  • 9
  • 50
  • 84