Search code examples
sendgrid

How do I reuse a dynamic template in multiple emails in SendGrid?


I have a dynamic template and I have about 20 different uses of it in my app, I am able to reuse it for all uses with dynamic content except the subject never applies.

I have tried passing the subject to the Mail instance itself as well as to the dynamic data, the template picks it up and replaces for all {{{subject}}} tags except for the actual email subject.

Dynamic templates have a settings tab where you can pass a subject but I want to do this dynamically, all my emails say “No subject” and it doesn’t make sense.


Solution

  • Okay, so the docs never mention this but adding a {{subject}} tag to the template settings itself allows you to set the email subject dynamically, while also using it in the template with the {{{subject}}} tag. Preview image