title: Can't send smtp email from network using C#, asp.net website
body: <p>I have my code here, it works fine from my home, where my user is administrator, and I am connected to internet via a cable network.
  But, problem is when I try this code from my work place, it does not work. Shows error:
  "unable to connect to the remote server"
  From a different machine in the same network:
  "A socket operation was attempted to an unreachable network 209.xxx.xx.52:25"</p>
  
  <p>I checked with our network admin, and he assured me that all the mail ports are open [25,110, and other ports for gmail].</p>
  
  <p>Then, I logged in with administrative privilege, there was a little improvement, it did not show any error, but the actual email was never received.</p>
  
  <p>Please note that, the code was tested from development environment, visual studio 2005 and 2008.</p>
  
  <p>Any suggestion will be much appreciated.
  Thanks in advance</p>
  
  <pre><code> try
      {
          MailMessage mail_message = new MailMessage("xxxxx@y7mail.com", txtToEmail.Text, txtSubject.Text, txtBody.Text);
          SmtpClient mail_client = new SmtpClient("SMTP.y7mail.com");
          NetworkCredential Authentic = new NetworkCredential("xxxxx@y7mail.com", "xxxxx");
          mail_client.UseDefaultCredentials = true;
          mail_client.Credentials = Authentic;
          mail_message.IsBodyHtml = true;
          mail_message.Priority = MailPriority.High;
          try
          {
              mail_client.Send(mail_message);
              lblStatus.Text = "Mail Sent Successfully";
          }
          catch (Exception ex)
          {
              System.Diagnostics.Debug.WriteLine(ex.Message);
              lblStatus.Text = "Mail Sending Failed\r\n" + ex.Message;
          }
      }
      catch (Exception ex)
      {
          lblStatus.Text = "Mail Sending Failed\r\n" + ex.Message;
      }
  </code></pre>