如何在ASP.Net中发送电子邮件? [英] How to send email in ASP.Net?

查看:100
本文介绍了如何在ASP.Net中发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我想知道如何点击网页上的按钮发送电子邮件?

用户将在文本框中输入他/她的电子邮件,他/她将按下SEND按钮。然后消息他/她将获得系统生成的ID以及他/她继续使用系统的一些说明。



谢谢:)

解决方案

使用ASP.NET和C#发送邮件/联系表单 [ ^ ]


有很多关于这个主题的文章,这里有两篇:

发送邮件/联系方式表格使用ASP.NET和C# [ ^ ]

http:// weblogs .asp.net / scottgu / 432854 [ ^ ]


全部你需要的可以在.NET FCL中找到。请从这里开始:

http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient%28v=vs.110%29.aspx [ ^ ],

http:// msdn.microsoft.com/en-us/library/system.net.mail.mailmessage%28v=vs.110%29.aspx [ ^ ]。



我希望你的ASP.NET托管为你提供对SMTP服务器的访问;我没有听说过没有此功能的主机包。



现在,如果你想根据从UI获取的输入数据发送邮件,你需要特别注意。这是容易打开漏洞的方法,这个漏洞允许有人将主机系统变成垃圾邮件发送的僵尸,或类似的东西。你需要阻止它。请参阅我以前的回答:无法发送邮件,它显示以下代码中的错误。 [ ^ ]。



-SA

Hi guys!
I would like to know on how to send an email by clicking a button in my web page?
The user will input his/her email in the text box and s/he will will press the SEND button. Then the message s/he will get will the system generated ID and some instructions to follow for him/her to continue using the system.

Thanks :)

解决方案

Send Mail / Contact Form using ASP.NET and C#[^]


There are a lot of articles about this subject, here are two of them:
Send Mail / Contact Form using ASP.NET and C#[^]
http://weblogs.asp.net/scottgu/432854[^]


All you need can be found in .NET FCL. Please start here:
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage%28v=vs.110%29.aspx[^].

I hope your ASP.NET hosting provides you with the access to a SMTP server; I never heard of hosting packages without this feature.

Now, you need to pay special attention if you want to send mail based in input data taken from UI. It's way to easy to open up a vulnerability which would allow someone to turn you host system a spam-sending zombie, or something like that. You need to prevent it. Please see my past answer: unable to send mail , it showing the error in below code .[^].

—SA


这篇关于如何在ASP.Net中发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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