Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I was trying to Send an Email to Registered email Id In forgot Password Page ,then i got this Error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was Authentication Required.


Code Is:

C#
public void Sendemail()
  {
          MailMessage message = new MailMessage();
          message.From = new MailAddress("admin@gmail.com", "admin");
          message.To.Add(Usertxt.Text);
          message.Subject = "Verification Email";
          message.Body = "Your Password is";
          message.IsBodyHtml = true;
          SmtpClient smtp = new SmtpClient();
          smtp.Host = "smtp.gmail.com";
          smtp.Port = 587;
          smtp.Credentials = new System.Net.NetworkCredential("admin@gmail.com", "admin123");
          smtp.EnableSsl = true;
          smtp.Send(message);
  }
Posted
Updated 11-Aug-15 23:07pm
v3
Comments
F-ES Sitecore 12-Aug-15 4:21am    
This is asked daily, google for "asp.net send email gmail" for the many reasons that this might fail. It is normally because you haven't configured your account to allow mails to be automated, or because the account needs to pass a manual captcha. Ultimately you shouldn't be sending email thorough gmail, use your web host's SMTP server.

Try This...


MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress("admin@gmail.com");

message.From = fromAddress;
message.To.Add(Usertxt.Text);


message.Subject = "Verification Email";
message.IsBodyHtml = true;


SmtpClient smtpClient = new SmtpClient("smtp.gmail.com");
smtpClient.Port = 587;
smtpClient.EnableSsl = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

smtpClient.UseDefaultCredentials = false;

smtpClient.Credentials = new System.Net.NetworkCredential("admin@gmail.com", "admin123");

smtpClient.Send(message);
 
Share this answer
 
Comments
Member 11804811 12-Aug-15 10:42am    
Thanks for Comment. I will try this code.
I think the credentials you are using are incorrect. Please verify once again.

Refer my previous answer with a fully working example - sending email to gmail from asp.net[^]
 
Share this answer
 
Comments
Member 11804811 12-Aug-15 10:42am    
Thanks for Comment. I will try this code
Most welcome.
Make sure your username/password credentials are fine. They seem to be causing the trouble and the server is not authenticating your request to send the email. You may want to recheck them in case of any problem.

My previous articles cover this topic in detail, please read them:
Sending emails over .NET framework, and general problems – using C# code[^]
Sending Emails Easily Using ASP.NET Helpers[^]
 
Share this answer
 
Thanks For all for ur Solution.I find the solution.
Changed setting of gmailid.
Allow unsecure Applogin ---> ON.

For more details,Please Refer Following Article.
http://www.smarterasp.net/support/kb/a1546/send-email-from-gmail-with-smtp-authentication-but-got-5_5_1-authentication-required-error.aspx[^]
 
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