0
Try
                    Dim rand As New Random()
                    randomCode = (rand.Next(999999)).ToString()
                    Dim smtp As New SmtpClient
                    Dim mail As New MailMessage


                    smtp.UseDefaultCredentials = False
                    smtp.Credentials = New Net.NetworkCredential("studentinfosytem2022@gmail.com", "bbuthrohpkmvhyav")
                    smtp.Port = 587
                    smtp.EnableSsl = True
                    smtp.Host = "smtp.gmail.com"

                    mail = New MailMessage
                    mail.From = New MailAddress("studentinfosytem2022@gmail.com")
                    mail.To.Add(txtEmail.Text)
                    mail.Subject = "Password Recovery"

                    mail.Body = "Your OTP Password recovery is " + randomCode
                    mail.IsBodyHtml = True

                    smtp.Send(mail)

                    MessageBox.Show("OTP was successfully sent to your Email. Please check your inbox.", "Sent", MessageBoxButtons.OK, MessageBoxIcon.Information)

                Catch ex As Exception
                    MsgBox(ex.Message.ToString, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Failed to send Message!")

                End Try

i always get the error "The SMTP server requires a secure connection or the Client was not authenticated." even i already enabled the 2-step verification and created app password on google.

how to fix this?

Jhunmark
  • 1
  • 1
  • Looks like duplicate: https://stackoverflow.com/questions/18503333/the-smtp-server-requires-a-secure-connection-or-the-client-was-not-authenticated – Artem S Nov 28 '22 at 03:43
  • Does this answer your question? [The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required?](https://stackoverflow.com/questions/18503333/the-smtp-server-requires-a-secure-connection-or-the-client-was-not-authenticated) – Tu deschizi eu inchid Dec 12 '22 at 01:44

0 Answers0