1
 Dim smtp As New SmtpClient
                    Dim mail As New MailMessage
                    smtp.Credentials = New Net.NetworkCredential("mail@gmail", "password")
                        mail.From = New MailAddress("mail@gmail.com")
                        mail.To.Add(totxt.Text$)
                        mail.Body = bodytxt.Text
                        If Not ListBox1.Items.Count <= 0 Then
                            Dim d As Integer
                            Dim attach As New Attachment(ListBox1.Items(d))
                            mail.Attachments.Add(attach)
                        End If
                    mail.Subject = subjecttxt.Text
                    smtp.EnableSsl = True
                    smtp.Port = "587"
                    smtp.Host = "smtp.gmail.com"
                    smtp.Send(mail)
                    smtp.Dispose()
                    done.Text = "Mail sent"
                    PictureBox4.BackgroundImage = My.Resources.tickfnl
                    dtls.Visible = False

I am trying to send email from my gmail account.But i am getting the error "The SMTP Server requires a secure connection".I even enabled LESS-SECURE APP login in my account settings.The password and email address is correct.I tried another email but same issue.Any fix ?

I TRIED ALL THE SOLUTIONS FROM THE DUPLICATE LINK,STILL THE SAME PROBLEM

**IF I REMOVE THIS LINE

smtl.enablessl=true

then i get this error

the server resposnse was 5.7.0 **

Fixed the error using EASendMail

St.Lue
  • 29
  • 6
  • 1
    `smtp.UseDefaultCredentials = False` before adding credentials seems to work for some people in fixing this issue – Sasha Nov 10 '17 at 12:24
  • 1
    Possible duplicate of [Gmail Error :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/20906077/gmail-error-the-smtp-server-requires-a-secure-connection-or-the-client-was-not) – Filburt Nov 10 '17 at 12:24
  • 1
    @Filburt,i tried the solutions from the duplicate post.They didn't work for me – St.Lue Nov 10 '17 at 12:34
  • try go here: https://g.co/allowaccess and allow access. Suggestion taken from: https://stackoverflow.com/a/26709761/3220424 – Sasha Nov 10 '17 at 16:15
  • @Jaxi,i did it before...but it didn't work....any other way ?/ – St.Lue Nov 11 '17 at 08:35

1 Answers1

1

Fixed it using EASendmail :

 Panel6.Visible = True
        done.Text = "Sending..."
        ''''''''''''''''''''''''
        Dim oMail As New SmtpMail("TryIt")
        Dim oSmtp As New EASendMail.SmtpClient()
        oMail.From = fromtxt.Text
        oMail.To = New AddressCollection(totxt.Text)
        oMail.Subject = subjecttxt.Text
        If html.CheckAlign = True Then
            oMail.HtmlBody = bodytxt.Text
        Else
            oMail.TextBody = bodytxt.Text
        End If
        Dim oServer As New SmtpServer(MailConfig.host.Text)
        oServer.Port = MailConfig.port.Text
        oServer.ConnectType = SmtpConnectType.ConnectSSLAuto
        oServer.User = fromtxt.Text
        oServer.Password = MailConfig.password.Text
        Dim r As Integer
        If ListBox1.Items.Count <= 0 Then
        Else
            oMail.AddAttachment(ListBox1.Items(r))
        End If
        oSmtp.LogFileName = Application.StartupPath & "\maillog.log"
        Try
            oSmtp.SendMail(oServer, oMail)
            done.Text = "Mail sent !"
            PictureBox4.BackgroundImage = My.Resources.tickfnl
        Catch ex As Exception
            aa = MsgBox(ex.Message)
            done.Text = "Sending failed."
            PictureBox4.BackgroundImage = My.Resources.excll
        End Try
St.Lue
  • 29
  • 6