Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 481k

How to resolve this issue when email is not verified?

Aug 3 2020 9:28 AM
Hi Team
 
I have this method and have enabled my authentication on my gmail, still get this exception;
  1. public Task SendAsync(IdentityMessage message)  
  2. {  
  3. // Plug in your email service here to send an email.  
  4. var mailMessage = new MailMessage();  
  5. mailMessage.To.Add(new MailAddress(message.Destination));  
  6. mailMessage.From = new MailAddress("[email protected]");  
  7. mailMessage.Subject = message.Subject;  
  8. mailMessage.IsBodyHtml = true;  
  9. mailMessage.Body = message.Body;  
  10. using (var smtp = new SmtpClient())  
  11. {  
  12. var credential = new NetworkCredential  
  13. {  
  14. UserName = "[email protected]",  
  15. Password = "***"  
  16. };  
  17. try  
  18. {  
  19. smtp.Host = "smtp.gmail.com";  
  20. smtp.Port = 587;  
  21. smtp.EnableSsl = true;  
  22. smtp.UseDefaultCredentials = false;  
  23. smtp.Credentials = credential;  
  24. smtp.Send(mailMessage);  
  25. }  
  26. catch (Exception ex)  
  27. {  
  28. throw;  
  29. }  
  30. }  
  31. return Task.FromResult(0);  
  32. }  
  33. }  
System.Net.Mail.SmtpException: 'The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at'

Answers (3)