【发布时间】:2010-04-08 23:24:42
【问题描述】:
大家好,
我一直在 web.conf 中存储 SQL 连接字符串,这很好,但现在我需要将 SMTP 凭据存储在受保护的地方。 web.conf 似乎是自受保护以来最有可能的地方,但如何存储它们?
我已将详细信息添加到我的 web.conf,但不知道如何引用它们
<system.net>
<mailSettings>
<smtp>
<network
host ="server"
userName ="username"
password ="password"
defaultCredentials =" false"
port =" 25"
/>
</smtp>
</mailSettings>
</system.net>
发送邮件:
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("billy.jones@networkroi.co.uk")
mail.To.Add(ToAddress)
'set the content
mail.Subject = "User Request Submitted via Client Portal"
mail.Body = "text in here"
mail.IsBodyHtml = True
' authenticatin
Dim basicAuthenticationInfo As New System.Net.NetworkCredential("username", "-password-")
'send the message
Dim smtp As New SmtpClient("servername")
smtp.UseDefaultCredentials = False
smtp.Credentials = basicAuthenticationInfo
smtp.Send(mail)
--琼斯
【问题讨论】:
标签: vb.net smtp web-config security credentials