title: How sent e-mail from ASP.NET site using GMail's SMTP server?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c">Sending email through Gmail SMTP server with C#</a>  </p>
  </blockquote>
  
  
  
  <p>I would like my ASP.NET MVC application to send some standard letters to users of the web site. For testing purposes I have no local SMTP server and my provider has non that I know of. So I have to use public services like GMail's SMTP.</p>
  
  <p>How do I send e-mail using <code>smtp.gmail.com</code> and my GMail account? What exactly should I put to <code>Web.config</code> and whot to code provided my e-mail is <code>drastomail@gmail.com</code> and my password is <code>password</code>?</p>
  
  <p>Thank you</p>
  
  <hr>
  
  <h2>EDIT</h2>
  
  <p>When I try following demo program:</p>
  
  <pre><code>class Program {
      static void Main(string[] args) {
          var client = new SmtpClient("smtp.gmail.com", 587) {
              Credentials = new NetworkCredential("puzzlehunters@gmail.com", "puzzlehunters111"),
              EnableSsl = true
          };
          client.Send("puzzlehunters@gmail.com", "puzzlehunters@gmail.com", "test", "testbody");
          Console.WriteLine("Sent");
          Console.ReadLine();
      }
  }
  </code></pre>
  
  <p>It fails with exception. Most inner exception carries this message: </p>
  
  <pre><code>No connection could be made because the target machine actively refused it 209.85.227.109:587
  </code></pre>
  
  <p>Also any all present answers (3 earliest) give me the same exception. What can I do with that?</p>