How to fix «<...> requires composer-plugin-api >=1.1.0 <2.3.0 -> found composer-plugin-api[2.3.0] but it does not match the constraint» for Composer 2?

Add the --ignore-platform-reqs flag to your Composer command, e.g.:

composer2 require --ignore-platform-reqs magepal/magento2-gmailsmtpapp:*