Due to low usage, this setting has been deprecated and has been removed. Click here for more information.
Section tags allow you to substitute in content in an SMTP message. Section tags are similar to substitution tags but are specific to the message, and not the recipient. You have to have a substitution tag value for each recipient, but you can have any number of section tags. Section tags can then contain Substitution tags for the recipient if needed. Section tags have to be contained within a Substitution tag since SendGrid needs to know which data to populate for the recipient. See the Section Tag Example Walkthrough below.
It's possible and acceptable to use only Substitution tags. However, that method is not DRY, and you may come against message size limitations.
When passing section
please make sure to only use strings as shown in our examples. Any other type could result in unintended behavior.
The format of the SMTP API section tag has the form:
_10{_10 "section": {_10 ":sectionName1": "section 1 text",_10 ":sectionName2": "section 2 text"_10 }_10}
How you flag your section tags may depend on the library you use to create your SMTP connection, the language you are writing your code in, or any intermediate mail servers that your servers will send mail through. In some cases -subVal-
may be the best choice while in other cases, %subVal%
, #subVal#
, or :subVal
may make more sense. The flag doesn't matter, as long as it's a unique string.
Do not use spaces inside your section or substitution tags! For example: %first name%
. The space breaks the string.
Do not nest section tags in sections! This causes your section to not be replaced.
Message body sent to SendGrid:
_14<html>_14 <body>_14 Hi :salutation,<br />_14 Thanks so much for joining us at our event!_14_14 <p>_14 You have registered for the following event:<br />_14 :event_details._14 </p>_14_14 Thanks,<br />_14 The SendGrid Team_14 </body>_14</html>
The accompanying X-SMTPAPI JSON header would look like:
_20{_20 "to": [_20 "example1@example.com",_20 "example2@example.com",_20 "example3@example.com"_20 ],_20 "sub": {_20 ":salutation": [":female", ":male", ":neutral"],_20 ":name": ["Alice", "Bob", "Casey"],_20 ":event_details": [":event1", ":event2", ":event1"],_20 ":event_date": ["Jan 1", "Feb 14", "Aug 11"]_20 },_20 "section": {_20 ":male": "Mr. :name",_20 ":female": "Ms. :name",_20 ":neutral": ":name",_20 ":event1": "New User Event on :event_date",_20 ":event2": "Veteran User Appreciation on :event_date"_20 }_20}
Alice receives:
_14<html>_14 <body>_14 Hi Ms. Alice,<br />_14 Thanks so much for joining us at our event!_14_14 <p>_14 You have registered for the following event:<br />_14 New User Event on Jan 1._14 </p>_14_14 Thanks,<br />_14 The SendGrid Team_14 </body>_14</html>
Bob receives:
_14<html>_14 <body>_14 Hi Mr. Bob,<br />_14 Thanks so much for joining us at our event!_14_14 <p>_14 You have registered for the following event:<br />_14 Veteran User Appreciation on Feb 14._14 </p>_14_14 Thanks,<br />_14 The SendGrid Team_14 </body>_14</html>
Casey receives:
_14<html>_14 <body>_14 Hi Casey,<br />_14 Thanks so much for joining us at our event!_14_14 <p>_14 You have registered for the following event:<br />_14 New User Event on Aug 11._14 </p>_14_14 Thanks,<br />_14 The SendGrid Team_14 </body>_14</html>