我已经编辑了webconfig文件,但是我有SmtpException "error sending mail"
。我的域端口是25。我已经仔细检查过。这是我的代码。什么问题?谢谢。
public void SendEmail(string toAddress, string fromAddress,string subject, string message)
{
try
{
using (var mail = new MailMessage())
{
mail.From = new MailAddress(fromAddress);
mail.To.Add(new MailAddress(toAddress));
mail.Subject = subject;
mail.Body = message;
mail.IsBodyHtml = true;
try
{
using (var smtpClient = new SmtpClient())
{
smtpClient.Host = "webmail.domain.com";
smtpClient.Port = 25;
smtpClient.Credentials = new NetworkCredential("blabla@domain.com", "pass");
smtpClient.Send(mail);
}
}
mail.Dispose();
}
}