How to configure email in Drupal 9 using Swift mailer module
Here we are going to discuss how to configure email in our Drupal instance using swift mailer module.
Here we are configuring email using Gmail SMTP server.
Please note, for this set up no need of any configurations in you local development environment
Use below command in project folder to install dependencies with module.
composer require drupal/swiftmailer
Now you can see Mail System module and Swift Mailer module in module list.
Enable these modules.
Go to configuration page and select Swift Mailer.
You can see Swift Mailer configuration page.
In Transport settings select SMTP and provide smtp server as smtp.gmail.com
Provide port and other details as above.
Provide your gmail credentials as user name and password.
Then click on Save configuration. You will see below success message.
Now we have to confirm our Drupal website can send mails.
For that make sure you have enabled Less secure App access On in your Google account
Click Manage your Google account -> Security
Now we are going to test whether test email is working or not.
Go to Test Tab in Swift Mailer configuration page.
Provide recipient mail ID. Click on Send button.
In your receiver mail Id you will receive Test mail as below.