PHP itself can not send mail. It requires a running and configured mail server on the hosting system which is accessed by the PHP
mail()
function after configuration in the
php.ini file.
But the PHP
mail()
function should not be used anymore nowadays where SSL is required.
The solution is to use one of the PHP mail frameworks like
GitHub - PHPMailer/PHPMailer: The classic email sending library for PHP[
^] or
GitHub - swiftmailer/swiftmailer: Comprehensive mailing tools for PHP[
^].
Once you have installed your preferred mail framework configure it and adapt the example code from the documentation. For using Gmail you will find many examples by searching the web for something like "php gmail <name_of_the _framework>".
Finally you have to configure the used Gmail account to allow connections from less secure apps:
Allow or disallow less secure apps to access accounts - G Suite Administrator Help[
^].
A final tip:
Never post sensitive information here. This includes email addresses as part of code snippets. I suggest to edit your question using the green 'Improve question' link to anonymise your Gmail address.