- Create a directory named "phpMailerLib" in the main directory.
- Open terminal and run "composer require phpmailer/phpmailer". For more info, goto https://github.com/PHPMailer/PHPMailer
- The directory structure should look like this. ├── sendEmail.php ├── phpMailerLib │ └── vendor │ ├── autoload.php │ ├── composer │ └── phpmailer └── README.md
- Now create app password (not your account password) in your google account. (Help: https://support.google.com/mail/answer/185833?hl=en#:~:text=Create%20%26%20use%20App%20Passwords)
- Set your email id as "Username"
- Set newly generated app password as "Password"
- Set Recipients, CC, BCC etc.
- Change the email body.
- run "php sendEmail.php" . Or, write a function as per your need.