We are in need of sending emails from Drupal through to Sendgrid. As far as we can see, there is no method as yet for doing this, so was looking at ways it could be implemented.
At the moment, a useful hook to add into sendgrid_integration to do this could be something like:
diff --git a/sites/all/modules/contrib/sendgrid_integration/inc/sendgrid.mail.inc b/sites/all/modules/contrib/sendgrid_integration/inc/sendgrid.mail.inc
index 078066a..6aa0c1f 100644
--- a/sites/all/modules/contrib/sendgrid_integration/inc/sendgrid.mail.inc
+++ b/sites/all/modules/contrib/sendgrid_integration/inc/sendgrid.mail.inc
@@ -131,6 +131,9 @@ class SendGridMailSystem implements MailSystemInterface {
}
}
+ // Allow other modules to modify the message, this was specifically added for templates
+ drupal_alter('sendgrid_integration_message', $sendgrid_message, $message);
+
//Add cc and bcc in mail if they exist.
$cc_bcc_keys = ['cc', 'bcc'];
$address_cc_bcc = [];
After this, I am looking at mappings to map the template_placeholders, and allow us to pass Drupal variables through for these to use. It may require some Drupal dev for each email, but it should alleviate some of the repetitive work.
If there is already anything that could help with this though, or approaches people have used, please let me know and I can take into consideration. Otherwise, I will go down a route similar to the Mandrill modules where it creates a new mapping entity to map templates to mailKeys.
Dan
Comments
Comment #2
retrodans CreditAttribution: retrodans commentedFor this, it would also be good to dynamically pull in the templates so you don't have to copy/paste them in. To do this, it would be good to get this method added into the code brought in by composer. (note, the below is a copy of the POST with a simple replacement to GET, nothing more)
Comment #3
Perignon CreditAttribution: Perignon commentedI am confused by your first statement, because this module does exactly that. This module allows for Drupal to send emails through Sendgrid.
In regards to templates, there is an outstanding issue to support SendGrid's templating system. Other than that, there are other modules that can be used to template emails, such as the HTMLmail module.
Comment #4
retrodans CreditAttribution: retrodans commentedThe requirement we have at the moment is for Drupal to pass variables to sendgrid, including the sendgrid template to render. It sounds like the outstanding issue on templates is basically what I am developing right now, so wonder if it is something worth sharing, as would at least create a consistent and relatively simple approach to using the Sendgrid templates.
Comment #5
Perignon CreditAttribution: Perignon commentedAlways willing to take contributions!
Comment #6
Perignon CreditAttribution: Perignon commented