Click here to Skip to main content
15,888,158 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
C#
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential("myemail", "<password>");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);

How do I solve this error
Posted
Updated 6-Jul-14 7:37am
v2
Comments
[no name] 6-Jul-14 13:31pm    
smtp.UseDefaultCredentials = false;
Thomas Daniels 6-Jul-14 13:31pm    
Is the email address in the format email@gmail.com or just email? If it is just email, you should use email@gmail.com. And, as Wes Aday said, you should set UseDefaultCredentials to false.

1 solution

try below
C#
SmtpClient smtp= new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("username", "pass");
smtp.Send(mm);
 
Share this answer
 
v2
Comments
polkj 6-Jul-14 13:55pm    
can this be used for hotmail or yahoo?
DamithSL 6-Jul-14 22:13pm    
for credentials you need to give gmail user name and password if you are using gmail smtp ("smtp.gmail.com")

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