title: Sending mail using SmtpClient in .net
body: <p>I am unable to send the mail using smtp client.
  here is the code:</p>
  
  <pre><code>SmtpClient client=new SmtpClient("Host");
  client.Credentials=new NetworkCredential("username", "password");
  MailMessage mailMessage = new MailMessage();
  mailMessage.from="sender@gmail.com";
  mailMessage.To.Add("recipient@gmail.com");
  mailMessage.body="body";
  mailMessage.subject="subject";
  client.Send(mailMessage);
  </code></pre>
  
  <p>The problem is that when I use this code in ASP.NET application, I do not receive any mails. When in asp.net I change the from mail address to username given in NetworkCredential, I receive mails.</p>
  
  <p>But in C# windows application, I can get emails, even if sender's email address is not valid.</p>