Install and configure SendGrid (Drupal 7)
Emails from websites tend to end up in spam boxes. This is getting a harder problem every day. It's very unpredictable and debugging is really hard.
In come transactional email services: these services deliver emails with a specific API or SMTP. They also offer tracking of email delivery.
There are many services on the market with such services.
The most common providers on drupal.org:
- Mandrill: https://www.drupal.org/project/mandrill.
- SendGrid: https://www.drupal.org/project/sendgrid_integration.
- Mailgun: https://www.drupal.org/project/mailgun.
- SendinBlue: https://www.drupal.org/project/sendinblue.
- Mailjet: https://www.drupal.org/project/mailjet.
In this tutorial I will focus on SendGrid. SendGrid is one of the biggest transactional email providers; it's moderately priced and is a good choice for SMB's.
Sending with the API or with SMTP?
Most transactional email providers recommend sending through an API. Sending with an API is faster and scales better. Using SMTP on the other hand has the advantage of being more flexible.
For example, when using Drupal, you could install the SMTP module (https://www.drupal.org/project/smtp) and switch between providers easily. When using an API: the setup is often tied to one provider.
Installation and configuration of the SMTP-module on Drupal 7
Install the SMTP module and configure it with these settings:
- SMTP Server - smtp.sendgrid.net
- SMTP Port - 587
- Use Encrypted Protocol - No. If you want encryption choose "Use SSL" and set SMTP Port to 465
- Username - SendGrid Username
- Password - SendGrid Password
Installation and configuration of the API on Drupal 7
- Install the SendGrid Integration module: https://www.drupal.org/project/sendgrid_integration.
- Install the Mail System module: https://www.drupal.org/project/mailsystem.
- Install the Composer Manager module: https://www.drupal.org/project/composer_manager.
- Run "composer require fastglass/sendgrid" in sites/all/. See https://www.drupal.org/project/sendgrid_integration/issues/2686377#comment-11262527.
- Enable the module.
- Go to /admin/config/services/sendgrid and enter the API Secret Key.
- Test if everything is working well under /admin/config/services/sendgrid/test by sending a test email message.