ASP.NET 中的电子邮件

发布于 2024-10-18 17:47:50 字数 289 浏览 6 评论 0原文

可能的重复:
发送到带有联系表单 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

装迷糊 2024-10-25 17:47:50

关于此的文章和教程并不缺乏。

旁注:能够通过电子邮件向用户发送密码意味着您以纯文本形式存储他们的密码。请,不要这样做。密码应以加密形式存储。如果用户忘记了密码,请通过电子邮件向他们发送临时链接,以便他们重置密码。

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.

赠我空喜 2024-10-25 17:47:50

您可以使用 SmtpClient 类发送.NET 应用程序中的电子邮件。

You could use the SmtpClient class to send an email in a .NET application.

白芷 2024-10-25 17:47:50

您的建议听起来像是存在安全风险。不建议通过电子邮件发送密码,因为这假设您将纯文本密码存储在某处。由于您应该只知道密码的加盐哈希,因此您可能想让用户重置密码。

我想如果您仍然有理由发送电子邮件,您可以查看此处开始的详细教程。但说真的,如果您不散列密码,则可能会危及所有用户的安全,如果您通过电子邮件发送密码,则更是如此。

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.

唠甜嗑 2024-10-25 17:47:50

简短的答案是,如上所述(+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:

  • Don't send passwords in clear text
  • Don't store passwords in clear text

When storing a password (if you don't have some framework that does all this for you)

  • Create a salt
  • Append the salt to the password
  • Hash the resulting string
  • Store the salt and resulting hash
  • Discard the password
  • When authenticating, add the salt to
    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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文