Possible Duplicate:
Sending email through Gmail SMTP server with C#
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.
How do I send e-mail using smtp.gmail.com
and my GMail account? What exactly should I put to Web.config
and whot to code provided my e-mail is drastomail@gmail.com
and my password is password
?
Thank you
EDIT
When I try following 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();
}
}
It fails with exception. Most inner exception carries this message:
No connection could be made because the target machine actively refused it 209.85.227.109:587
Also any all present answers (3 earliest) give me the same exception. What can I do with that?