Sendgrid Functionality and Limitations

Sendgrid: Functionality and Limitations

The official Sendgrid Handlebars documentation (opens in a new tab) does not specify many of the desired functionality NHM requires, this documentation will help to clarify what configurations are possible and not possible.

Possible Functionalities

The following are tools that can be used:

  • HTML Elements

  • Inline CSS

  • Custom fonts integration

  • Using hosted images

  • Dynamic objects and substitutions both basic and deep (i.e. {{tickets.link}} )

  • Conditionals that show/hide/render html and objects

    • If, Else, Else If
    • If with a root
    • Unless
    • greaterThan
    • lessThan
    • Equals
    • notEquals
    • And
    • Or
    • Length
  • Nested Conditionals

    • {{#if this.male}}
         {{#if this.date}}
            <p>{{this.date}}</p>
         {{/if}}
      {{else if this.female}}
         {{#if this.date}}
            <p>{{this.date}}</p>
         {{/if}}
      {{/if}}
  • Iteration of objects (each)

    • {{#if people}}
         <p>People:</p>
         {{#each people}}
            <p>{{this.name}}</p>
         {{/each}}
      {{/if}}
  • Conditionals that compare an object value to an object and a non-object (strings, integers, etc.).

    • {{#notEquals data.object "string"}}
       
      {{#Equals events.name "Gift of Membership"}}
  • Object failsafes (i.e using an object that does not exist or is routed incorrectly will result in not displaying the object but will not affect the overall email functionality or cause errors)

  • Date formatting

  • Multiple API Keys

Not Possible Functionalities

By following the official Handlebars.js documentation (opens in a new tab) and comparing it to the Sendgrid Handlebars documentation (opens in a new tab), there are certain concepts and functionalities that cannot be fullfilled in Sendgrid's handlebars.js.

The following are tools that cannot be used:

  • Custom Helpers / Register Helper functions.

    • Handlebars.registerHelper('loud', function (aString) {
          return aString.toUpperCase()
      })
  • Multiple email senders (current email sender: ticketing@nhm.org).

  • The total size of your email, including attachments, must be less than 30MB.

  • The total number of recipients must no more than 1000. This includes all recipients defined within the to, cc, and bcc parameters, across each object that you include in the personalizations array.

  • The total length of custom arguments must be less than 10000 bytes.

  • Unicode encoding is not supported for the from field.

  • The to.name, cc.name, and bcc.name personalizations cannot include either the ; or , characters.