title: Unable to send email from SMTP
body: <p>I am sending an email through the smtp of the company it has no credentials only port 25 but i keep getting this error <code>System.Net.Mail.SmtpException: Failure sending mail. ---&gt; System.IO.IOException: Unable to read data from the transport connection: The connection was closed.</code>, note that i tried to send the email from the hotmail server and it worked (host: smtp.live.com, port 587 and my email credentials)</p>
  
  <p>this is my code:</p>
  
  <pre><code> public static void SendEmail(EmailObject email)
      {
          System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
          smtp.Host = email.Host;
          smtp.EnableSsl = false; // I Tried to set it true as well
          smtp.UseDefaultCredentials = false;
          smtp.DeliveryMethod = SmtpDeliveryMethod.Network; // i tried to remove it
          if (!string.IsNullOrEmpty(email.Username) &amp;&amp; !string.IsNullOrEmpty(email.Password))
              smtp.Credentials = new NetworkCredential(email.Username, email.Password);
          if (email.Port != 0)
              smtp.Port = email.Port;
          MailMessage mailMessage = new MailMessage();
          mailMessage = new MailMessage();
          mailMessage.Subject = email.Subject;
          if (email.Attachments != null)
          {
              foreach (EmailAttachment emailAttachment in email.Attachments)
              {
                  Attachment attachment = new Attachment(emailAttachment.AttachmentStream, emailAttachment.AttachmentName, emailAttachment.ContentType);
                  mailMessage.Attachments.Add(attachment);
              }
          }
          System.Net.Mail.MailAddress mailAddress = new System.Net.Mail.MailAddress(email.MailAddress, email.DisplayName);
          mailMessage.From = mailAddress;
          foreach (var address in email.Recepients.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
          {
              mailMessage.To.Add(address);
          }
          mailMessage.IsBodyHtml = true;
          mailMessage.Body = email.Body.ToString();
          smtp.Send(mailMessage);
      }
  </code></pre>