How to fix Gmail SMTP authentication error.
Now, Google has decided to begin phasing out Less Secure Apps from May 30th, 2022. Google Workspace and Google Cloud Identity users won’t be affected right away, but support for Less Secure Apps will still be phased out for those users at a later date.
So, How to Switch From Less Secure Apps?
Now, you can set up an app password in your Google account. An app password works like an alternate password for your account. It can only be used by the applications you share it with, so it’s more secure than sharing your primary password.
If you’d like to use an app password, you'll need to turn on two-factor authentication for your Google account first. After that, you can create an app-specific password.
To do so, go to Google Account > Security > Signing in to Google > App passwords.
Step 1: You can select App.
Step 2:Select your device (You can use a custom name for the device. Like, I set Ubuntu previously).
Step 3: Click to GENERATE.
Step 4: Yes! Your app password is ready. Now you can use it for authentication.
Note: Just like your normal password, this app password grants complete access to your Google Account. You won't need to remember it, so don't write it down or share it with anyone.
Source: Sign in with App Passwords.