The URL for the Google help page with settings for Gmail:
Additional mail settings
Sometimes additional permissions and settings are required for everything to work. Gmail requires you to let third-party applications connect to your mailbox.
If this setting is disabled, then it won't be possible to send an email - when you try to do this, a service message with an error will pop up.
How to let an app connect to Gmail
Open your browser and sign in to your Google account.
Go to the help center and click on the corresponding link to open the access control page. Here is the address: https://myaccount.google.com/lesssecureapps.
In the opened window, move the selector to let the connection.
If Google has blocked the connection
Even after you have permitted third-party applications to connect, Google can deny access - you need to confirm that it is you who are requesting it.
Attention! Make sure to grant access to your own application. Proceed to this section only after you have completely configured the form for sending an e-mail and tried to send an email.
Permitting the connection
Log into your Google account. See if there are security notices on the homepage and go through them.
If you find a message about a blocked connection, confirm that you are the one who tried to connect.
Go to https://accounts.google.com/DisplayUnlockCaptcha and confirm that you are allowing access to your email to the application that recently tried to connect.
Follow the instructions and build your application here.