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):
'Less secure apps' setting allows usage of username/main-password credentials.
Alternatively you can use OAuth 2.0 -or- App Passwords:
There are several flows depending on your scenario:
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:
VAT: PL 5213195875
02-707, Warsaw Poland