Click here to Skip to main content
15,902,749 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am getting following error when i tried to send mail through my asp.net c# code

C#
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. y2sm48568819pfi.39 - gsmtp


What I have tried:

I am getting following error when i tried to send mail through my asp.net c# code

C#
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. y2sm48568819pfi.39 - gsmtp


my code is:
C#
MailMessage mm = new MailMessage("xyz@gmail.com", "xyz@gmail.com");
           mm.Subject = "Password Recovery";
           mm.Body = string.Format("Hi ,<br /><br />Your password is .<br /><br />Thank You.");
           mm.IsBodyHtml = true;
           SmtpClient smtp = new SmtpClient();
           smtp.Host = "smtp.gmail.com";
           smtp.EnableSsl = true;
           NetworkCredential NetworkCred = new NetworkCredential();
           NetworkCred.UserName = "xyz@gmail.com";
           NetworkCred.Password = "xyz";
           smtp.UseDefaultCredentials = true;
           smtp.Credentials = NetworkCred;
           smtp.Port = 587;
           smtp.Send(mm);
Posted
Updated 1-Jun-16 4:45am
v3

1 solution

 
Share this answer
 
v2
Comments
Kishor-KW 1-Jun-16 10:47am    
I used it. please see a code
Richard MacCutchan 1-Jun-16 10:54am    
See my updated solution, there is more required than you have provided. Note, this is not a coding issue but one of usage of gmail.
Kishor-KW 1-Jun-16 11:09am    
thanx man...I spend 3 days on it...finally got a solution...thank you very much
@Richard MacCutchan
F-ES Sitecore 1-Jun-16 11:06am    
This is why you shouldn't repost questions. People looking at this don't know what you've been told already so are mainly wasting their time.
Richard MacCutchan 1-Jun-16 11:13am    
Thanks, I wasn't aware this was a repost.

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