Possible duplicate:
Sending email through a Gmail SMTP server using C #
I would like my ASP.NET MVC application to send standard emails to site users. For testing purposes, I do not have a local SMTP server, and my provider does not have the one I know about. Therefore, I must use public services such as GMail SMTP.
How do I send an email using smtp.gmail.commy GMail account? What exactly should I put in Web.config, and for the code, provided that my email address drastomail@gmail.comand my password are password?
thank
EDIT
When I try to run a demo program:
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();
}
}
. :
No connection could be made because the target machine actively refused it 209.85.227.109:587
(3 ) . ?