1

I've looked this up and it seems other people have had the same issue mainly because Gmail was blocking the application's access, however I've turned on the "allow less secure apps to connect" option and the problem remains.

Here's the complete error message I get from ASP.net when I try to connect.

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

I've tried connecting using port 465 and I get a time-out (I assumed it was the Explicit/Implicit SSL problem)

Here's the code that I'm using to send the emails.

Dim Mail As New MailMessage
    Dim EmailToMail As New MailAddress(EmailTo, EmailToName)
    Mail.To.Add(EmailToMail)
    Dim FromE As New MailAddress(EmailFrom, "Something")
    Mail.From = FromE
    Mail.Body = Body
    Mail.Subject = Title

    Dim SmtpClient As New SmtpClient("smtp.gmail.com", 587)

    SmtpClient.UseDefaultCredentials = False
    Dim SmtpCredentials As New System.Net.NetworkCredential("MyEmail", "MyPassword")
    SmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
    SmtpClient.EnableSsl = True

    SmtpClient.Send(Mail)

I've also tried setting UseDefaultCredentials to True, which didn't work.

  • Do you have two-step verification? If so this could be the issue and if not I still have a complete answer here covering all of this here: http://stackoverflow.com/questions/23360415/fail-sending-email-unable-to-connect-the-remote-server/23362096#23362096 – Trevor Jan 27 '15 at 16:51

3 Answers3

1

your credentials are stored only within variable not within smtp instance.

set

SmtpClient.Credentials = SmtpCredentials

also make sure you use System.Net.Mail

0

This can happen if your password no longer meets Gmail's complexity criteria. Try logging in and changing it.

theduck
  • 2,589
  • 13
  • 17
  • 23
0

There can be a few issues.

  1. Your firewall could be blocking it... (bypass it)
  2. The port is blocked... (you need to allow it)
  3. If you have two-step verification enabled on your email account...
  4. Your credentials you are creating are never applied to the server credentials.

I have already answered this same question before here and will answer all of your problems. It also includes a link for sending the emails that I have answered as well.

Community
  • 1
  • 1
Trevor
  • 7,777
  • 6
  • 31
  • 50