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-req=composer-plugin-api flag to your Composer command, e.g.:

composer2 require magepal/magento2-gmailsmtpapp:* --ignore-platform-req=composer-plugin-api