title: E-mail Issue "Failure sending mail"
body: <p>I am using Razor to send an E-mail through SMTP. I am using the same bit of code to do this in a different site, but I am getting an error on this one. I've changed the Web.config SMTP Settings. I'm not sure what I may be doing wrong.</p>
  
  <pre><code>@helper SendContactEmail(ContactFormModel formModel)
  {
  MailMessage mm = new MailMessage("contact@chasecomputerservices.com",          "eric@chasecomputerservices.com");
  mm.Subject = "New mail from J&amp;M Services Contact Form";
  //mm.Body = string.Format("Name: {0}\nEmail: {1}\n\nMessage: {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)
  {
      &lt;h2&gt;@ex.Message&lt;/h2&gt;
      &lt;p&gt;@ex.StackTrace&lt;/p&gt;
  }
  }
  </code></pre>
  
  <blockquote>
    <p>The error I'm getting is "Failure sending mail" and the StackTrace is
    "at System.Net.Mail.SmtpClient.Send(MailMessage message) at
    ASP._Page_macroScripts_Contact_cshtml.b__16(TextWriter
    __razor_helper_writer) in c:\Dev\SVN\Main\UmbracoApps\umbJMServices\umbJMServices\macroScripts\Contact.cshtml:line
    262".</p>
  </blockquote>
  
  <p>Line 262 is the client.Send(mm);</p>
  
  <p>I am getting an InnerException: </p>
  
  <blockquote>
    <p>System.IO.IOException: Unable to read data from the transport
    connection: net_io_connectionclosed. at
    System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer,
    Int32 offset, Int32 read, Boolean readLine) at
    System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader
    caller, Boolean oneLine) at
    System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader
    caller) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint
    servicePoint) at
    System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
    at System.Net.Mail.SmtpClient.GetConnection() at
    System.Net.Mail.SmtpClient.Send(MailMessage message)</p>
  </blockquote>