This step should have been completed upon the installation of Drupal 8 for getting PHPMailer function
Install Composer
# curl -sS https://getcomposer.org/installer | php
Move Composer binary to usr bin path
# mv composer.phar /usr/bin/composer
Check Composer Version
# composer --version
Go to Drupal root Directory and execute
Drupal Installation Directory - /var/www/html
# cd /var/www/html/
# composer require 'drupal/phpmailer_smtp:^2.1'
Restart PHP-FPM / apache2 Service
# systemctl restart php-fpm
# systemctl restart apache2
Verify Library in Drupal vendor folder
# ls -l vendor/phpmailer/
Add SMTP Credentials in Drupal Configuration
- Login as admin in Drupal
- Enable Module - Extend- > Install new Module -> PHPMailer SMTP
- Configuration -> System - > PHPMailer SMTP