Click here to Skip to main content
15,949,686 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:

C#
emailid = table.Rows[0]["EmailId"].ToString();
					MailMessage mail = new MailMessage();
					mail.To.Add(emailid);
					mail.From = new MailAddress(txtemail.Text.ToString());
					mail.Subject = "Registration";
					string Body = "Please Approve my Registration";
					mail.Body = Body;
					SmtpClient smtp = new SmtpClient("127.0.0.1");
					smtp.Host = "smtp.gmail.com";
					try
					{
						smtp.Send(mail);
						Response.Write("Mail sent successfully");
						clearcontrol();
					}
					catch (Exception ex)
					{
						Response.Write("Mail send failed");
					}
Posted
Updated 27-Aug-11 20:07pm
v2

1 solution

gmail does not use port 25 for smtp. See fopr code here http://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c[^]
 
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