Email Form Gmail Security Problems

I have set up the Contact form and added my Gmail email address and other details but I had a warning from Google highlighting that something was trying to access my account.

I also get this on the web page: **There was an error sending the form: SMTP Error: Could not authenticate. **

This is the code in my config (obviously edited):

  'email' => [
    'transport' => [
      'type' => 'smtp',
      'host' => 'smtp.gmail.com',
      'port' => 465,
      'security' => true,
      'auth' => true,
      'username' => 'sul@s***m.com',
      'password' => '***',
    ]
    ],

You probably need to change your gmail setting to allow access through less secure apps. https://myaccount.google.com/lesssecureapps

But Google will give you lots of warnings about it being very dangerous. They even consider Thunderbird a less secure app that shouldn’t be used.

If you don’t have another SMTP server to try, you could give Mailgun a shot. They do SMTP, and you get the first 10,000 emails a month free.