SMTP Authentication Support Module for Drupal

Published Jan 4, 2021
Updated May 12, 2021
By Simon

If you want to send email from your Drupal site then this is the module to use. It uses the PHPMailer Class via the PHPMailer package.

From the Github repository

PHPMailer is a full-featured email creation and transfer class for PHP

PHP mail() class can be used but you will end up with delivery issues.

Up until now, you may have been using the UI or FTP method to install and update your modules but from my experience trying to set up SMTP module and downloading the PHP Mailer Class and adding it to your libraries directory is a futile job. Now is the time if any to learn Composer.

If you are unfamiliar with Composer, it is the PHP package manager, similar to NPM or Yarn for JavaScript. I have written a short guide to Composer at Getting Going Composer.

Info

https://www.drupal.org/project/smtp

Actively maintained Yes, report installs 148,153
Requires No extra requirements
Libraries requires 6.x PHPMailer which is the latest version. "phpmailer/phpmailer": "^6.2"

Once installed correctly you can check Status Report /admin/reports/status If it isn't installed correctly you will get a message.

Image
SMTP status on the Drupal status report page

Basics

Install with Composer

composer require drupal/smtp

Running the above command with download everything needed, it's that simple.

Then either visit the Extend page and Install or run the Drush command if you are using Drush.

drush smtp en

For Manual UI install you need to download the library and put it the libraries directory yourself, as I said I have tried to do this on some non-Composer managed sites and it has been futile. In the end, I used Composer to install SMTP even on non-Composer managed sites and this worked.

Another option is the PHPMailer SMTP module. I haven't used this so I can not recommend it but from what I have read it can be installed without the need for Composer.

Once you have installed SMTP visit the configuration page.

SMTP Authentication Support Configuration

Manage > Configuration > System > SMTP Authentication Support
/admin/config/system/smtp

You will need your SMTP server name and you will also need the port number, for the mail service I use it is 465 but sometimes it maybe 587.

Search outgoing email server for your Email service provider and you should find the relevant information.

You will also need your email address and password for SMTP Authentication.

Once you have filled in the server and authentication details there are few other optional settings as outlined below.

E-mail options

Email options allow you to specify the name and email address that emails come from if different from the site default.

You can allow messages to be sent formatted in HTML by checking Allow to send e-mails formatted as HTML.

Testing and debug check built-in

After you have set up everything you can send a test e-mail and also turn on debugging if you have problems.

That's about it. Now your emails will use your SMTP server and not the PHP mail class.

Thanks for reading and be sure to reach out if you have a question or need help.

Tags