Does Gmail block IMAP due to less secure app policy?
'Less secure apps' setting is still available for custom domains (Google Workspace or Google Cloud Identity): https://myaccount.google.com/lesssecureapps 'Less secure apps' setting allows usage of username/main-password credentials.
Alternatively you can use OAuth 2.0 -or- App Passwords:
OAuth 2.0 There are several flows depending on your scenario:
Web app: https://www.limilabs.com/blog/oauth2-gmail-imap-web-applications
Installed/desktop app: https://www.limilabs.com/blog/oauth2-gmail-imap-installed-applications
Service account/daemon: https://www.limilabs.com/blog/oauth2-gmail-imap-service-account
-or-
A simpler solution is to use App passwords: Turn on 2-Step Verification for the account (required), then create an application specific password.
You can find more details on App Passwords here: https://www.limilabs.com/blog/using-app-passwords-with-gmail