我有这个发送邮件的代码:
public bool SendMail(MailMessage message)
{
message.From = new MailAddress(AppProperties.FromMailAddress, AppProperties.FromDisplayName);
SmtpClient smtp = new SmtpClient { EnableSsl = AppProperties.EnableSsl };
try
{
smtp.Send(message);
return true;
}
catch (Exception)
{
return false;
}
}
并已将 web.config 配置为在本地主机中使用 IIS 5.1 发送邮件(如答案所建议):
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="localhost"
userName=""
password=""
defaultCredentials="false"
port="25" />
</smtp>
</mailSettings>
</system.net>
在 Windows XP 中使用 IIS 5.1 发送邮件需要做什么?有可能做到吗?我想是的,正如你所说,因为我没有得到任何异常(exception),但我没有在目的地收到它。如果我应该输入用户名和密码,那必须是什么?
请您参考如下方法:
您应该首先安装 SMTP 服务器(Windows 组件 > IIS > SMTP 服务),然后配置它以启用中继。
IIS > Default SMTP Server > Properties Access > Authentication
Access Control > Anonymous Access - Checked
Relay Restrictions > Relay > Select - Only the list below > Add > 127.0.0.1
