Manual:$wgSMTP/Gmail

This page provides an example for setting the  configuration parameter if you would like to use Gmail for sending emails by your wiki.

You will need to generate an application password for your instance of Mediawiki in your Google account's security preferences. Google discourages app passwords as insecure, but it's the only choice for non-interactive authentication with Google. So, you first have to enable two-factor authentication on your Gmail account. Then you can create an app password in your Google account, and use that in the password setting shown above.