Last post Feb 03, 2021 03:30 AM by XuDong Peng
Feb 02, 2021 08:38 AM|kengkit|LINK
Hi guys.. i getting this error while trying to send an email via smtp.gmail.com
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
The following is my code for sending emails out.
email@example.com is a Google business email account.
This web application is parked at www.byebye.com which let system user send an email out.
Anything wrong to my code or setting?
Public Function SendEmail() As Boolean
Dim success As Boolean = False
Dim [to] As String = "firstname.lastname@example.org"
Dim cc As String = ""
Dim bcc As String = ""
Dim from As String = "email@example.com"
Dim fromName As String = "HELLO WORLD"
Dim userName As String = "firstname.lastname@example.org"
Dim password As String = "fd##4jhAbWQ"
Dim attachment As Attachment = Nothing
Dim client As New SmtpClient()
client.EnableSsl = "True"
client.Credentials = New System.Net.NetworkCredential(userName, password)
client.Port = "587"
client.Host = "smtp.gmail.com"
Using mail As New MailMessage()
mail.From = New MailAddress(from, fromName)
mail.ReplyTo = New MailAddress("email@example.com")
mail.Sender = mail.ReplyTo
If [to].Contains(";") Then
Dim _EmailsTO As String() = [to].Split(";".ToCharArray())
For i As Integer = 0 To _EmailsTO.Length - 1
If Not [to].Equals(String.Empty) Then
mail.Subject = "Testing Mail from Gmail Server"
mail.SubjectEncoding = System.Text.Encoding.UTF8
mail.Body = "HELLO WORLD"
mail.IsBodyHtml = True
mail.BodyEncoding = System.Text.Encoding.UTF8
If attachment IsNot Nothing Then
success = True
Catch ex As Exception
' end try
Feb 03, 2021 03:30 AM|XuDong Peng|LINK
Google may block sign in attempts from some apps or devices that do not use modern security standards. Since these apps and devices are easier to break into, blocking them helps keep your account safer.
For example, some third-party applications such as desktop mail clients ( such as Microsoft Outlook ,Mozilla Thunderbird,etc).
Therefore, you have to enable Less Secure Sign-In (or Less secure app access) in your google account.
After sign into google account, go to --->
You could also refer to this similar case:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication