Skip to content
Michael Bagnall edited this page Oct 10, 2023 · 2 revisions

This module overrides default email sending behavior and sending emails through SendGrid Transactional Email service instead. Emails are sent via a web service and does not function like SMTP therefore there are certain caveats with other email formatting modules. Read below for details.

Failures to send are re-queued for sending later. Queue of failed messages are run on a 60 minute interval.

REQUIREMENTS


Module dependencies:

Backdrop's Mailsystem needs to be changed to use SendGrid. This can be done with by leveraging the dependent Mailsystem module.

This module requires that the SendGrid API Wrapper class is available. A compatible version is packaged with this module and does not need to be installed separately. However another module dependency for X Autoload is required to load the third-party library for SendGrid.

Installation


  1. Navigate to Functionality Tab and enable SendGrid Integration in the Mail category.

  2. Configure your SendGrid API-Key in admin/config/services/sendgrid

  3. Confirm that the mail system is setup to use SendGrid for how you wish to run you website. If you want it all to run through SendGrid then you set the System-wide default MailSystemInterface class to "SendGridMailSystem".

HTML Email


In order to send HTML email. Your installation of Drupal must generate an email with the proper headers. SendGrid Integration modules looks for the content type of the email to be set to "text/html" in the header (i.e. "Content-Type"="text/html"). A text version of the email is also sent at the same time.

If the message does not have the content type set to "text/html" the message will be stripped of any tags and converted to text.

We do not recommend MIMEmail module because it sets the content-type header of a message to "multipart/mixed" instead of strictly "text/html". In addition, the MIMEmail module attempts to template emails and include inline CSS that is not compatible with SendGrid template system. If you want to use MIMEmail, we suggest using the SMTP module and not this module.

If you want to work on a solution for MIMEmail and contribute it back to the module, we gladly accept community contributions!

OPTIONAL


If sending email fails with certain (pre-defined) response codes the message be added to Cron Queue for later delivery. In order for this to function, you must configure Cron running period and when it is possible also add your drupal site to crontab (Linux only), read more about cron at https://docs.backdropcms.org/documentation/setting-up-cron.

If you would like a record of the emails being sent by the website, installing Maillog (https://www.backdropcms.org/project/maillog) will allow you to store local copies of the emails sent. SendGrid does not store the content of the email.

DEBUGGING


Debugging this module while installed can be done by installing the Maillog module (https://www.backdropcms.org/project/maillog). This module will allow you to store the emails locally before they are sent and view the message generated in the SendGrid email object.

RESOURCES


Information about the SendGrid PHP Library is availabe on Github:
https://github.com/taz77/sendgrid-php-ng

Clone this wiki locally