电子邮件问题"Failure sending mail"



我使用Razor通过SMTP发送电子邮件。我在另一个网站上使用了相同的代码,但我在这个网站上遇到了错误。我已更改Web.config SMTP设置。我不确定我做错了什么。

@helper SendContactEmail(ContactFormModel formModel)
{
MailMessage mm = new MailMessage("contact@chasecomputerservices.com",          "eric@chasecomputerservices.com");
mm.Subject = "New mail from J&M Services Contact Form";
//mm.Body = string.Format("Name: {0}nEmail: {1}nnMessage: {2}", formModel.Name, formModel.Email, formModel.Comment);
mm.Body = "testing body";
mm.IsBodyHtml = false;
SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
try
{
    client.Send(mm);
}
catch (Exception ex)
{
    <h2>@ex.Message</h2>
    <p>@ex.StackTrace</p>
}
}

我得到的错误是"发送邮件失败",StackTrace是"位于System.Net.Mail.SmtpClient.Send(MailMessage消息)ASP_Page_macroScripts_Contact_cshtml.b_16(TextWriter__razor_helper_writter),位于c:\Dev\SVN\Main\UmbracoApps\umbJMServices\umbJMServices \macroScripts\Contact.cshtml:line262英寸.

第262行是客户端。发送(mm);

我得到一个InnerException:

System.IO.IOException:无法从传输读取数据连接:net_io_connectionclosed。在System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[]缓冲区,Int32偏移量、Int32读取、布尔读取行)System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader调用者,布尔oneLine)System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader调用者)在System.Net.Mail.SmtpConnection.GetConnection(ServicePointservicePoint)System.Net.Mail.SmtpTransport.GetConnection(ServicePoint ServicePoint)位于的System.Net.Mail.SmtpClient.GetConnection()System.Net.Mail.SmtpClient.Send(MailMessage消息)

我在公司内部遇到了这个问题,因为防火墙拒绝了邮件。请与您的系统管理员核实是否有防火墙。

最新更新