在我的MVC4应用程序中,我正在尝试使用Web.config发送邮件以进行配置设置.我有剪纸作为模拟SMTP服务器运行.当我尝试使用smtpClient并在我的代码中设置host ="localhost"(也就是说,不是通过Web.config)时,一切正常.
我的Web.config
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="someone@somewhere.net">
<network
host="localhost"
userName=""
password=""
defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>
Run Code Online (Sandbox Code Playgroud)
我的代码
SmtpClient client = new SmtpClient();
client.Send(myEmailObject);
Run Code Online (Sandbox Code Playgroud)
错误
未指定SMTP主机