This project is read-only.

SMTPs with GMail

Jul 15, 2010 at 6:18 PM


I tried to send a simple mail without attachment by gmail server.

But it does'nt work.

I tried to send it by port 485 with SSL, and by port 587 with TLS but no one is working.

Can you give me a valid source code to send a simple mail with a gmail account.



Jul 16, 2010 at 4:16 PM

It seems port no is wrong.Port no is 465.
Here is a complete code work with GMail ssl.

   SmtpClient cl = new SmtpClient();
   cl.ServerName = "";
   cl.Port = 465;
   cl.Ssl = true;
   cl.AuthenticateMode = SmtpAuthenticateMode.Auto;
   cl.UserName = "";
   cl.Password = "yourPassword";
   SmtpMessage mg = new SmtpMessage();
   mg.From = "";
   mg.To.Add(new MailAddress(""));
   mg.Subject = "GMail test";
   mg.BodyText = "GMail test body";
   var rs = cl.SendMail("<>", "<>", "", "", mg.GetDataText());