Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
The following error is occured in my code.I want to send mail through smtp service via gmail. :

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. g14sm3507891wfh.10.

Code written by:

emailid = table.Rows[0]["EmailId"].ToString();
					MailMessage mail = new MailMessage();
					mail.From = new MailAddress(txtemail.Text.ToString());
					mail.Subject = "Registration";
					string Body = "Please Approve my Registration";
					mail.Body = Body;
					SmtpClient smtp = new SmtpClient("");
					smtp.Host = "";
						Response.Write("Mail sent successfully");
					catch (Exception ex)
						Response.Write("Mail send failed");
Updated 27-Aug-11 20:07pm

1 solution

gmail does not use port 25 for smtp. See fopr code here[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900