PHP - send mail using gmail smtp

  • Go to the https://myaccount.google.com/lesssecureapps and enable "Allow less secure apps"
  • Install composer if doesn't already exists
  • Install phpmailer library with command - composer require phpmailer/phpmailer
  • Copy the code from above and paste it into your index.php file
  • Execute created file with command - php index.php

Comments