ASP.NET SMTP +网络配置
我正在开发一个遗留应用程序,它的代码中有这个逻辑,不幸的是我无法修改。我在 web.config 中有正确的设置,并且想知道如果我列出了正确的 SMTP 服务器,web.config 设置会处理凭据吗?
如果不是,我有哪些选项可以使用此代码发送电子邮件?
string str13 = "";
str13 = StringType.FromObject(HttpContext.Current.Application["MailServer"]);
if (str13.Length > 2)
{
SmtpMail.SmtpServer = str13;
}
else
{
SmtpMail.SmtpServer = "localhost";
}
SmtpMail.Send(message);
Im working on a legacy app that has this logic in its code that I cant modify unfortunately. I have the proper settings in the web.config and was wondering if i list the proper SMTP server would the web.config settings take care of the credentials?
If not what options do i have for sending email out with this code?
string str13 = "";
str13 = StringType.FromObject(HttpContext.Current.Application["MailServer"]);
if (str13.Length > 2)
{
SmtpMail.SmtpServer = str13;
}
else
{
SmtpMail.SmtpServer = "localhost";
}
SmtpMail.Send(message);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,
System.Web.Mail
没有公开任何用于指定凭据的设置。不过,发送经过身份验证的电子邮件是可能的,因为 System.Web.Mail 是构建在 CDOSYS 之上的。 这是一篇知识库文章,介绍了如何执行此操作,但您基本上必须修改消息本身:这是否适合您的情况,我不确定......
System.Web.Mail
does not expose any settings for specifying credentials, unfortunately. It is possible to send authenticated emails, though, becauseSystem.Web.Mail
is built on top of CDOSYS. Here's a KB article which describes how to do it, but you basically have to modify some properties on the message itself:Whether that works for your situation or not, I'm not sure....