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 "Signing in to Google", turn on "2-Step Verification", follow up the upcoming pages to complete.
Gmail APP Pass 1
4. Go back to "Signing in to Google", you will see a new option "App passwords".
Gmail APP Pass 2
5. Click on "App passwords", select the app and device you want to generate the app password for.
6. Choose Select app and choose Mail, choose Select device and choose Windows Computer, Generate.
Gmail APP Pass 3
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 4
 
If you get a problem or if you have any questions, please contact our support.