Gmail is disabling Less Secure Apps: How to send SMTP emails with APP Passwords

Programming, error messages and sample code > sample code
To use your Google Account in an SMTP code, please follow these steps to generate an App Password.
An App password is a 16-digit passcode that gives a non-Google app or device permission to access your Google Account. Learn more about how to sign in using App Passwords.
1. Go to your Google Account.
2. Select Security.
3. Under "How you sign in to Google", turn on "2-Step Verification", follow up the upcoming pages to complete.
Gmail APP Pass 1
4. Go back to "How you sign in to Google", enter "2-Step Verification" again.
Gmail APP Pass 2
5. Scroll down to the bottom of the page, and click on "App passwords"
Gmail APP Pass 3
6. Type any App name you want, then click on "Create".
Gmail APP Pass 4
7. You will get a 16-digit passcode, copy it and use it as SMTP password of your Gmail account in your scripts. Please note there is NO whitespace when using the passcode, the code in the screenshot is more readable.
Gmail APP Pass 5
If you get a problem or if you have any questions, please contact our support.