同煤集团吧,陈慧琳老公是谁,齐一心
webmail 帮助器 - 众多有用的 asp.net web 帮助器之一。webmail 帮助器使我们更容易从 web 应用程序中使用 smtp 来发送电邮。
为了演示电子邮件的使用,我们将创建用于技术支持的输入页面,让用户向另一个页面提交该页面,然后发送一封有关支持问题的电子邮件。
如果您曾构建过本教程中的 demo 应用程序,那么站点中应该存在拥有如下内容的 _appstart.cshtml 页面:
@{ websecurity.initializedatabaseconnection("users", "userprofile", "userid", "email", true); }
如需初始化 webmail 帮助器,请向您的 appstart 页面添加以下 webmail 属性:
@{ websecurity.initializedatabaseconnection("users", "userprofile", "userid", "email", true); webmail.smtpserver = "smtp.example.com"; webmail.smtpport = 25; webmail.enablessl = false; webmail.username = "support@example.com"; webmail.password = "password-goes-here"; webmail.from = "john@example.com"; }
smtpserver: 发送电邮所使用的 smtp 服务器的名称。
smtpport: 发送 smtp transactions (电邮) 所用的服务器端口。
enablessl: true,如果服务器应该使用 ssl (secure socket layer) 。
username: 发送电邮所用的 smtp email 账户的名称。
password: smtp 电邮账户的密码。
from: 出现在 from 栏中的电邮地址(通常与 username 相同)。
然后创建输入页面,名为 email_input:
<!doctype html> <html> <body> <h1>request for assistance</h1> <form method="post" action="emailsend.cshtml"> <label>username:</label> <input type="text name="customeremail" /> <label>details about the problem:</label> <textarea name="customerrequest" cols="45" rows="4"></textarea> <p><input type="submit" value="submit" /></p> </form> </body> </html>
输入页面的作用是收集信息,然后把数据提交到一个能够将信息作为邮件来发送的新页面。
然后创建用于发送电邮的页面,名为 email_send:
@{ // read input var customeremail = request["customeremail"]; var customerrequest = request["customerrequest"]; try { // send email webmail.send(to:"someone@example.com", subject: "help request from - " + customeremail, body: customerrequest ); } catch (exception ex ) { <text>@ex</text> } }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论