System.Net.Mail.SmtpException:
Failure sending mail. --->
System.Net.WebException:
Unable to connect to the remote server --->
System.Net.Sockets.SocketException:
No connection could be made because the target machine actively refused it xx.x.xx.xxx:25
我SMTP主机IP地址上面我无法得到它的邮件是抛出上述异常。下面的smtp例外无法发送邮件
是我的代码
mail.From = new MailAddress(email.From.EmailAddress,email.From.FullName);
mail.Subject = email.Subject;
mail.Body = email.Body;
if (email.Body.Contains("<html>"))
{
mail.IsBodyHtml = true;
}
if (!email.ExcludeAttachment && !string.IsNullOrEmpty(email.AttachmentPath))
mail.Attachments.Add(new Attachment(email.AttachmentPath));
client = new SmtpClient();
client.Host = ConfigurationSettings.AppSettings["SmtpServer"].ToString();
client.Send(mail);
显示您的代码。 – Arash
mail.From = new MailAddress(email.From.EmailAddress,email.From.FullName); mail.Subject = email.Subject; mail.Body = email.Body; if(email.Body.Contains(“”)) { mail.IsBodyHtml = true; (email.AttachmentPath)) } if(!email.ExcludeAttachment &&!string.IsNullOrEmpty(email.AttachmentPath)) mail.Attachments.Add(new Attachment(email.AttachmentPath)); client = new SmtpClient(); client.Host = ConfigurationSettings.AppSettings [“SmtpServer”]。ToString(); client.Send(mail); –
这是我的代码。 –