vapor-community / sendgrid-kit

📧 A Swift on Server SDK for the SendGrid API
https://swiftpackageindex.com/vapor-community/sendgrid-kit
MIT License
10 stars 14 forks source link

Template not sent when using templateID #6

Open cuyogomez opened 4 years ago

cuyogomez commented 4 years ago

Hey everyone, have any of you sent a main using the dynamic template generated by SendGrid? According to documentation if we sent the templateId it will not care what we set to the content and subject but the API requires to have content set. So, when I set the content to text like [ "type": "text", "value": "Condominus Invitation" ], I receive the email with just that set in the content and not sending the template generated. I've been investigating the issue and it seems the documentation it's not sending the content property within the example they have here. I tried to send the post manually and it didn't worked as well. In summary, I'm stuck in sending template emails created in SendGrid. Any tips? Thanks in advance.

svanimpe commented 3 years ago

Hi @cuyogomez,

I had a similar question and found out that you can pass the template data in a Personalization: https://github.com/vapor-community/sendgrid-kit/blob/e5f7506f9cc6b10cf0f52cb08ab4b9a43cfba6dc/Sources/SendGridKit/Models/Personalization.swift#L24

So if you set the templateId in the SendGridEmail and the substitutions for your handlebars in the Personalization, it should work.