In one of my Drupal 8 work I needed to configure SMTP using swiftmailer Module. The module extends the basic mail sending functionality which is provided by Drupal by delegating all mail handling to Swift Mailer library. This library provides features, such as :
- Sends e-mails directly through an SMTP server of our choice, that is a locally installed MTA agent such as sendmail or the mail functionality which is provided by PHP.
- Sending HTML e-mails(MIME).
- Adds file attachments along with mails.
- Adds inline images to e-mails.
The Swift Mailer module depends on the mailsystem module which is responsible for making the Swift Mailer module available to Drupal. You have to install SwiftMailer Library before enabling swiftmailer module. The preferred way to install Swiftmailer is via Composer. Use the following command for this:
$ composer require swiftmailer/swiftmailer
Once the module is installed, you can set Drupal to use swiftmailer as default mail system to send HTML mails with the following settings.
Configure Mail System
Configure the Mail System page (admin/config/system/mailsystem) to Global Mail System configuration.
Configure SwiftMailer Settings
Go to the Mail System page (admin/config/swiftmailer/transport) to configure Swift Mailer transport and message settings.
For more details click here