我正在尝试设置简单但完整的 ASP.NET MVC 4 Web 应用程序,我可以在其中向特定地址发送电子邮件,我在控制器调用中为 SMPT 设置和代码配置 web.config 文件,但我收到错误消息“SMTP未指定主机”
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="myEmail@hotmail.co.uk">
<network host="smtp.live.com" port="25" userName="myEmail@hotmail.co.uk" password="myPassword" defaultCredentials="true"/>
</smtp>
</mailSettings>
在控制器类
var mailMessage = new MailMessage();
mailMessage.To.Add("yourEmail@hotmail.co.uk");
mailMessage.Subject = "testing 2 ";
mailMessage.Body = "Hello Mr. Aderson";
mailMessage.IsBodyHtml = false;
var smptClient = new SmtpClient { EnableSsl = false };
smptClient.Send(mailMessage);
非常感谢