Template variables
Every {{variable}} MailLand supplies or recognises in campaigns, automations and API or SMTP sends, with aliases, defaults and the rules
This page lists every {{variable}} that MailLand fills in for you, and the rules that apply to the ones you supply yourself. Names are case-sensitive: {{firstName}} is not {{firstname}}.
The rules
- A tag is exactly
{{name}}. Two opening braces, the name, two closing braces. The name can hold any character except braces and line breaks, so{{custom_order-id}}works. - No spaces inside the braces.
{{ firstName }}is read as a variable literally namedfirstName(with the spaces). It has no value, so the message is refused as described under A missing value. - No inline defaults, filters, conditions or loops.
{{firstName|there}}is not supported. Set a default value on the template instead. - A value is never searched again. If a value itself contains
{{other}}, that text is sent as it is. - Subject, HTML and plain text are all rendered. The preview text of a campaign counts as well.
Escaping
| Part of the message | What happens to a value |
|---|---|
| HTML body | HTML-escaped, so a name containing & or < cannot break your markup |
| Plain-text body | Inserted as it is, Ben & Jerry's stays exactly that |
| Subject | Inserted as it is, except that line breaks and other control characters become one space (a subject is a header) |
Campaigns and automations
For a campaign or an automation email, MailLand builds these variables for each recipient from the subscriber record. This is the full list.
| Tag | Alias | Value | Always supplied? |
|---|---|---|---|
{{firstName}} | {{first_name}} | The subscriber's first name | No. Absent when the subscriber has no first name (a blank counts as none). A default can fill it |
{{lastName}} | {{last_name}} | The subscriber's last name | No. Same as firstName |
{{fullName}} | {{full_name}} | First and last name joined by a space | No. Present when at least one of the two exists |
{{email}} | none | The subscriber's email address | Yes. Cannot have a default |
{{subscriberId}} | {{subscriber_id}} | The subscriber's opaque public identifier | Yes. Cannot have a default |
{{custom_<field>}} | none | The value of the custom field <field> on the subscriber | No. Absent when the subscriber has no such field |
{{<field>}} | none | The same custom field under its bare name | No. Only when the bare name is not one of the built-in names above |
{{unsubscribe_url}} | {{unsubscribeurl}} | The recipient's own signed unsubscribe link | Yes, for marketing mail (see below) |
Both spellings of an alias give the same value. The camelCase names are the documented ones; the snake_case aliases keep older templates working.
A custom field called email or firstName never replaces the built-in value: the built-in always wins, and you reach the custom one as {{custom_email}}.
The unsubscribe link
{{unsubscribe_url}} (alias {{unsubscribeurl}}) is filled by MailLand with a signed link to the public unsubscribe page. It carries the same token as the List-Unsubscribe header of that message.
- It is supplied for marketing mail: every campaign and automation email, and every API or SMTP send made with a marketing-stream credential. Unsubscribe links must be enabled on the platform, which they are by default.
- The platform value always wins. A value of the same name from a subscriber field, a template default or your own
variablesis replaced. - A marketing message is never refused because of this tag, since MailLand supplies it.
- Transactional mail does not get it. If a transactional send names
{{unsubscribe_url}}, you must supply the value yourself, like any other variable. Without a value the send is refused (see A missing value). - Unless the API key has the transactional unsubscribe link on. A transactional key (API, SMTP or both) can turn on
transactionalUnsubscribeLink(see API keys). Its sends then get{{unsubscribe_url}}filled per recipient, with noList-Unsubscribeheader, and an opt-out through it blocks only email sent with that key. This holds for SMTP submissions too. - In a template preview the tag shows a link with a sample token. It is not a working link.
See Campaigns for the pre-flight check that blocks a campaign without a visible unsubscribe link.
Default values
A template can hold a default for each placeholder, in variableDefaults (for example { "firstName": "there" }). The default is used only when the recipient has no usable value, a recipient's own value always wins, and a default for firstName also answers {{first_name}}.
- Defaults apply to campaigns and automations only. They do not apply to API or SMTP sends.
email,subscriberIdandsubscriber_idare always supplied and cannot have a default.- A value is one line of at most 200 characters, and a template holds at most 50 defaults.
See Default Values for the API.
API and SMTP sends with a template
MailLand supplies no recipient variables on these sends: there is no firstName unless you send it. Every variable is one you pass.
| Where you pass it | Applies to |
|---|---|
variables at the top of the request | Every recipient of the request |
variables on a recipient (to[].variables, or the recipient in a batch) | That recipient only, and it wins over the request-level value of the same name |
Details:
- Any name you choose works. The only platform-supplied names are
{{unsubscribe_url}}and{{unsubscribeurl}}, and only on a marketing-stream credential or a transactional key with the unsubscribe link on. - The tags a template uses must each have a value, either in the request or on the recipient. A value of
nullcounts as supplied and renders as an empty string. - Template defaults (
variableDefaults) are not applied here. - Inline
htmlContentsent with novariablesat all, which is what an SMTP relay message is, is sent as written: a{{in it is your own text. The one exception is{{unsubscribe_url}}on a marketing-stream credential. On a transactional credential the same tag is refused unless you supply a value or the key has the unsubscribe link on. - Scheduled follow-ups use
{{firstName}},{{lastName}},{{fullName}}and{{email}}taken from the recipient's name and address, plus the variables recorded with the original send.
See Templates and Batch sending.
A missing value
A message is never sent with a raw {{name}} in it. When a tag has no value and no default:
| Where | What happens |
|---|---|
| Campaign, before scheduling or sending | The template_variables pre-flight item fails and the request is refused with 422 CAMPAIGN_PREFLIGHT_FAILED. Nothing goes out |
| Campaign, a recipient still lacking a value when the worker runs | That recipient is skipped and not mailed |
| Automation email | That recipient's email is skipped |
POST /v1/transactional/send | 422 TEMPLATE_VARIABLE_MISSING, naming the missing variables. Nothing is sent |
POST /v1/transactional/send-batch | That recipient is skipped and listed in rejectedRecipients with the reason template_variable_missing: name, name. The others are sent |
POST /v1/transactional/send or an SMTP submission on a transactional credential, with content that names {{unsubscribe_url}} or {{unsubscribeurl}} and no variables | 422 UNSUBSCRIBE_URL_UNAVAILABLE (SMTP: 554 5.6.0). Nothing is sent, and a scheduled send is refused when you create it. Send the message as marketing, turn on the unsubscribe link for the key, remove the tag, or pass your own value in variables |
What does not exist
MailLand does not supply variables for a preference-center link, a view-in-browser link, your company address, the current date or year, or a tracking link. Tracking is added to your message automatically. If you need a value of this kind, pass it yourself as a variable (API sends) or store it as a custom field on the subscriber (campaigns and automations).