Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Support SendGrid's hosted templating system.
https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html
Comment | File | Size | Author |
---|---|---|---|
#10 | sendgrid_template_2.patch | 837 bytes | Matt B |
#6 | sendgrid_template.patch | 973 bytes | Matt B |
Comments
Comment #2
Perignon CreditAttribution: Perignon commentedThis is on hold till I can get this finished: https://github.com/taz77/sendgrid-php-ng/issues/3
Comment #3
Alex Bukach CreditAttribution: Alex Bukach commented@Perignon, did you start any work on this? I would like to contribute to this functionality if possible, since I need in on an ongoing project.
Comment #4
Perignon CreditAttribution: Perignon commentedBe glad to get any help possible. I just moved back to the US from Europe so I will not be able to do any Drupal coding for weeks.
Comment #5
johannez CreditAttribution: johannez as a volunteer commentedI might post a proper patch for this later, but in the mean time I can tell you how I enabled Sendgrid templates.
First in your own _mail() or _mail_alter() function you want to attach the template_id and variables substitutions like this
Then unfortunately you have to hack the mail() function in the sendgrid.mail.inc file.
I put it in the area where the $sendgrid_message object gets all the sets..
Comment #6
Matt BI can confirm johannez's hack works. Here is the patch for sendgrid.mail.inc
Comment #7
Perignon CreditAttribution: Perignon commentedPatch needs to be made against the root of the module, not your site :-D
If you can fix the patch I would be happy to commit it.
Comment #8
Perignon CreditAttribution: Perignon commentedAnd also create the patch against dev, never create a patch against a release on any module on D.O
Comment #9
Perignon CreditAttribution: Perignon commentedComment #10
Matt BOk try this one then, previously I had just used the patch generated from the PAAS I use, whereas I've now cloned 7.x-1.x and created this patch on my local machine.
Comment #12
Perignon CreditAttribution: Perignon commentedPatch has been committed to 7.x-1.x branch.
Comment #13
retrodans CreditAttribution: retrodans commentedI have been working on my own mapping implementation (as per issue https://www.drupal.org/node/2821974), and have integrated so the code in this patch. But my finding was that you need to include the below line for it to work with HTML templates along with setTemplateId for it to use the HTML template (otherwise you just get the plain text template)
$sendgrid_message->setHtml(' ');
Did you have a different workaround for this? Wonder if it also needs to be part of this patch for it to work with HTML templates.
As we maybe only want this for some users, maybe a config setting like the others would be a solution
Dan
Comment #14
Perignon CreditAttribution: Perignon commentedThis problem may be with the wrapper library. I am rewriting the library to use the V3 API from Sendgrid. You can follow along with that development here:
https://github.com/taz77/sendgrid-php-ng/tree/v3-api-upgrade
I am working on rewriting all the unit tests right now. I have not tested this code against the API yet.
Comment #15
Perignon CreditAttribution: Perignon commentedComment #17
drfuzetto CreditAttribution: drfuzetto as a volunteer commentedWhen I add a template_id to $message['sendgrid']['template_id'], it gets posted to SendGrid but SendGrid blocks it from being sent out.
I am getting this:
"This email was not sent because the SMTPAPI header was invalid."
Doesn't really say what is invalid. If I don't include the template_id, the email is sent ok.
Anyone else have this issue?
Comment #18
asak CreditAttribution: asak commented@drfuzetto - 2 things to solve that:
1. make sure you're using the legacy templates, not the new version.
2. add
$message['headers']['content-type']= 'text/html';
to the mail_alter hook.