-1

Error: The SMTP server requires a secure connecton or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at.

    private void SendMail(string email, string firstname)
    {
       
        MailAddress from = new MailAddress($"{email}", $"{firstname}");
       
        MailAddress to = new MailAddress($"{email}");
       
        MailMessage m = new MailMessage(from, to);
       
        m.Subject = "TEST";
       
        m.Body = "<h2>TEST</h2>";
       
        m.IsBodyHtml = true;
       
        SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
       
        smtp.Credentials = new NetworkCredential("jewralyapp@mail.ru", "password");
        smtp.EnableSsl = true;
        smtp.Send(m);
    }

I want to send a letter to the mail, but the error that I indicated above comes out, here is the code, can you tell me what is wrong?

2 Answers2

0

I see that your email is @mail.ru and the server is gmail, is that correct? I think you need to use your gmail account. You also need enable weaker credentials on your gmail account. Forgot what they actually call it but it's on gmail security setting.

0

I had also faced the same problem.

  1. Your SmtpClient is gmail, but you are using "jewralyapp@mail.ru"!!!
  2. Make sure to set "Less secure app access" to ON in your Gmail security setting.

In my case, the problem was solved.

ouflak
  • 2,458
  • 10
  • 44
  • 49