Drupal and Amazon SES

Drupal and Amazon SES SMTP server

Hello everyone!

Today I would like to write a bit on configuring SMTP Amazon SES with Drupal. We set up our Drupal installation on Amazon EC2 server. We wanted to change default mail() method in Drupal to SMTP server. As we already used Amazon we wanted to try SES. Here is the short info how we manage to run and configure it.

Setup Amazon SES account for Drupal

I assume that You already have Amazon account for purpose of this tutorial. If You don't have one, you need to sign up in order to use Amazon services first.

After You log in go and visit this page. This is simple dashboard that shows the statistics for Your SMTP server. SES has some limits and You can check them on this page as well.

Drupal - Amazon SES console

Let's set up SMTP account for Drupal. On the left side of Dashboard page you should see sidebar menu. Go to SMTP Settings. Under this page You will have access to data that are required for SMTP access (Server name, port)

Drupal - Amazon SES settings for SMTP

The only thing that we don't have are SMTP credentials - username and password. Click on "Create My SMTP Credentials button". It will take us to IAM page where You can create new user account. You can leave the default name or provide Your own. Click create button. After that You can download the credentials. But keep in mind that there are not the credentials that You'll be using in Drupal!

Drupal - Amazon SES - create user

After new user is created we need to setup his credentials for Drupal purposes. Go to IAM user page and click on Your created user.

Under Security credentials there are Sign-In credentials. Click on Manage Password. You can choose between password generated by IAM or Your own. Pick one of the option and remember the password. That's the one You'll be using in Drupal.

Drupal - Amazon SES - manage password

 

Setup From: account on SES for Drupal

We already have the user credentials for connecting with SMTP server in Drupal. There is one more thing we need to care about. In order to be able to set From: field we need to authorize the email. Go to SES console or click this link. There are two ways of verifying sender. You can authorize specific emails or whole domain.

If You want to authorize specific email (we will use this option) click Verify a new Email Address. Type Your email and click Verify this Email Address. You will receive email with activation link. After activation You should see the status verified.

Drupal - Amazon SES - verify sender email

If You want to authenticate whole domain You need to setup DKIM. You can read more about this process here.

 

Setup Your Drupal installation for Amazon SES

Now this is the final step. We need to configure Drupal for Amazon SES. First, we need a module that can change Drupal's native mail() function to SMTP protocol. In our example we will use SMTP Authentication Support module. It's really nice, easy to implement module for SMTP also with support for Drupal 8. Download and install this module. Go to configuration page (Menu Toolbar -> Configuration -> System -> SMTP Authentication Support).

What fields You need to set:

  • Turn this module on or off - set to ON
  • SMTP server - get the information from SMTP settings page on Amazon
  • SMTP port - 25, 465 or 587 (also listed on SMTP settings page)
  • Use encrypted protocol - Use TLS
  • Username - created username on Amazon SES
  • Password - password for this user (not authentication keys!)
  • E-mail from address - email that You verified

Drupal - SMTP settings for Amazon SES

Rest of the fields are optional. Really useful fields are:

  • E-mail address to send a test e-mail to - You can test if SMTP is working
  • Enable debugging - use it only for test, disable on production enviroment. If the setting doesn't work You will have a debugging messages with information what was wrong.

 

 

Basically that's it. After that You can start sending emails from Drupal using Amazon SES, using forms etc. This module will overwrite default Drupal functionality so You don't have to bother to change anything else. No need to change Your old code for sending emails etc.

Our services: