ASP.NET 中的电子邮件
可能的重复:
发送到带有联系表单 asp.net 的电子邮件
如何使用 C# 从 ASP.NET 页面发送电子邮件,如果忘记密码,密码将自动通过电子邮件发送到备用 ID。我需要如何使用 C# 从 ASP.NET 页面发送电子邮件。
Possible Duplicate:
sending to an email with contact form asp.net
How to send email from ASP.NET page using C# as for forget password, password will be automatically emailed to the alternate id. I need how is it possible to send email from ASP.NET page using C#.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
关于此的文章和教程并不缺乏。
旁注:能够通过电子邮件向用户发送密码意味着您以纯文本形式存储他们的密码。请,请不要这样做。密码应以加密形式存储。如果用户忘记了密码,请通过电子邮件向他们发送临时链接,以便他们重置密码。
There is no shortage of articles and tutorials on this.
Side note: Being able to email the user their password implies that you're storing their password in plain text. Please, please don't do that. Passwords should be stored in an encrypted form. If the user forgets their password, email them a temporary link for them to reset their password.
您可以使用 SmtpClient 类发送.NET 应用程序中的电子邮件。
You could use the SmtpClient class to send an email in a .NET application.
您的建议听起来像是存在安全风险。不建议通过电子邮件发送密码,因为这假设您将纯文本密码存储在某处。由于您应该只知道密码的加盐哈希,因此您可能想让用户重置密码。
我想如果您仍然有理由发送电子邮件,您可以查看此处开始的详细教程。但说真的,如果您不散列密码,则可能会危及所有用户的安全,如果您通过电子邮件发送密码,则更是如此。
What you are suggesting sounds like a security risk. It is inadvisable to send a password through email, since this assumes your are storing the plain text password somewhere. Since you should only know the salted hash of the password, you probably want to make the user reset their password instead.
I suppose if you still have some reason to send an email you can check out an extensive tutorial here to start. Seriously though, You can compromise all of your users security if you are not hashing there passwords, and even more so if you are emailing them out.
简短的答案是,如上所述(+1'd btw),使用 SmtpClient 类。
然而,通过电子邮件发送密码是很危险的。根据经验,
存储密码时(如果您没有某种框架可以 对
新提供的密码,散列
结果字符串,并与您的比较
存储的哈希值
如果用户忘记了密码,请向该用户发送一封电子邮件,其中包含一次性使用、时间敏感(1 小时后过期?)、唯一链接以重置其密码。要求用户在密码重置表单上手动提供他/她的帐户名或其他识别标准也是一个好习惯。
The short answer is, as stated above (+1'd btw), to use the SmtpClient class.
However, it's dangerous to go emailing passwords around. As a rule of thumb:
When storing a password (if you don't have some framework that does all this for you)
the newly provided password, hash the
resulting string, and compare to your
stored hash
If a user has forgotten their password, send that user an email containing a one-time use, time-sensitive (expires in 1 hour?), unique-link to reset his/her password. It's also a good practice to require the user to manually provide his/her account name or other identifying criteria on the password-reset form.