To quickly install Composer in the current directory, run the following script in your terminal. To automate the installation, use the guide on installing Composer programmatically.
#cd /var/www/html
#php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
#php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
If the result Installer corrupt, visit https://getcomposer.org/download/
#php composer-setup.php
#php -r "unlink('composer-setup.php');"
Most likely, you want to put the composer.phar into a directory on your PATH, so you can simply call composer from any directory (Global install)
#mv composer.phar /usr/local/bin/composer
Install PHPMAILER
#composer require phpmailer/phpmailer