我正在使用 MVC3,需要向用户发送电子邮件。我不想使用 gmail 服务器。但是,我确实想使用服务器 10.1.70.100。我不明白我做错了什么。这是我的代码:
var fromAddress = new MailAddress("sum1@abc.com", "From Name"); var toAddress = new MailAddress(EmailID, "To Name");
const string fromPassword = "";//To be Filled
const string subject = "Verification Mail";
string body = "You have successfully registered yourself. Please Enter your Verification code " + code.ActivatedCode;
var smtp = new SmtpClient
{
Host = "10.1.70.100",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential(),
Timeout = 100000
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
有人可以建议一种我不必提供凭据的方法吗?