Variables
Variables let you insert dynamic values into fields such as header names, header values, directory paths, and other supported inputs, as well as into Templates.
User attributes
User attribute variables insert data of the message sender. The sender's email address is looked up in the data imported from the Directory service, and the matching user's attributes are used. You can preview the imported values in the users drill-down on the Domains page.
These variables are available in Templates applied by signature and disclaimer rules. A variable is replaced with an empty string when the sender is not found in the directory or the attribute has no value.
| Variable | Description |
|---|---|
{id} | User identifier |
{mail} | Email address |
{firstName} | First name |
{lastName} | Last name |
{displayName} | Display name |
{notes} | Notes |
{phoneNumber} | Phone number |
{mobileNumber} | Mobile number |
{streetAddress} | Street address |
{city} | City |
{postalCode} | Postal code |
{country} | Country |
{jobTitle} | Job title |
{department} | Department |
{company} | Company |
{employeeId} | Employee identifier |
Photo
The photo variables insert the user's photo with the image data embedded directly in the message, so no external hosting is needed. The image format (JPEG, PNG, or GIF) is detected automatically. Photo variables produce output only in the HTML version of a template; in the plain-text version they are replaced with an empty string.
| Variable | Description |
|---|---|
{photo} | Ready-to-use HTML <img> tag with the embedded photo in its original size |
{photo:WIDTH} | Same as {photo} with a fixed width in pixels, for example {photo:100} |
{photo:WIDTHxHEIGHT} | Fixed width and height, for example {photo:100x60} |
{photo:xHEIGHT} | Fixed height, for example {photo:x60} |
{photoData} | Bare image data (data URI) without any markup, so you can write your own tag around it, for example <img src="{photoData}" alt="Photo" /> |
Dimensions are given in pixels and can range from 1 to 2000; a value outside this range is ignored and the original size is kept.
Message
Misc
| Variable | Description |
|---|---|
{message:id} | Unique message identifier; value of the X-MSH-Id header added by the application |
{message:subject} | Message subject |
Envelope
| Variable | Description |
|---|---|
{message:envelope:sender} | Envelope sender email address |
{message:envelope:recipients} | Comma-separated list of recipient email addresses |
{message:envelope:recipients:count} | Number of To and Cc recipients |
Size
| Variable | Description |
|---|---|
{message:size} | Message size in kilobytes (default unit) |
{message:size:b} | Message size in bytes |
{message:size:kb} | Message size in kilobytes |
{message:size:mb} | Message size in megabytes |
{message:size:gb} | Message size in gigabytes |
Headers
| Variable | Description |
|---|---|
{message:headers:count} | Total number of message headers |
{message:header:HEADER_NAME} | Value of a specific header; replace HEADER_NAME with the actual header name |
Attachments
| Variable | Description |
|---|---|
{message:attachments:count} | Number of attachments |
{message:attachments:size} | Total attachment size in kilobytes (default unit) |
{message:attachments:size:b} | Total attachment size in bytes |
{message:attachments:size:kb} | Total attachment size in kilobytes |
{message:attachments:size:mb} | Total attachment size in megabytes |
{message:attachments:size:gb} | Total attachment size in gigabytes |
{message:attachments:filenames} | Comma-separated list of attachment filenames |
{message:attachments:filenames_perline:PREFIX} | Attachment filenames on separate lines, each prefixed with PREFIX |
Misc
| Variable | Description |
|---|---|
{misc:guid} | Randomly generated GUID in the format 00000000-0000-0000-0000-000000000000 |
{misc:random:MIN-MAX} | Random integer between MIN and MAX (inclusive) |
{misc:random:value1,value2,value3} | Random value selected from a comma-separated list |
{misc:date:FORMAT} | Current date and time formatted using Java date pattern characters (y, M, d, H, m, s, etc.) |
Template syntax
Beyond simple substitution, fields and templates support a lightweight template syntax: conditional blocks, comparisons, string helpers, and iteration over message collections.
If a template contains invalid syntax (for example an orphan {else}), the text is kept
unchanged - template syntax can never break message processing. Anything the engine does not
recognize, including unmatched braces, stays literal text.
Conditionals
A {#if} block renders its content only when the variable has a non-empty value:
{#if mobileNumber}| M: {mobileNumber}{/if}
{else} renders the alternative branch:
{#if company}{company}{else}MSH Software{/if}
{else if ...} chains conditions; the first matching branch wins:
{#if and mail mobileNumber}E: {mail} | M: {mobileNumber}
{else if mail}E: {mail}
{else if mobileNumber}M: {mobileNumber}
{/if}
Conditions accept plain variable names (subject, firstName, company, ...).
Colon-modifier forms such as message:subject cannot appear inside a condition.
Logic operators
Conditions combine variables with and, or, not - written without parentheses, with any
number of operands for and / or:
{#if and mail mobileNumber}both present{/if}
{#if or phoneNumber mobileNumber}some number exists{/if}
{#if not company}no company set{/if}
{#if and displayName jobTitle company}complete header{/if}
{else if} accepts the same operators: {else if or mail mobileNumber}.
Comparison blocks
The operators eq, neq, lt, lte, gt, gte compare two operands - variable names,
quoted strings, or numbers - as a block with an optional {else} branch:
{#eq department "Research"}R&D team{else}Business team{/eq}
{#lt a b}a is smaller{else}a is not smaller{/lt}
{#gt a 5}more than five{/gt}
When both operands are numbers the comparison is numeric (9 sorts before 10); otherwise
the operands compare as strings.
String helpers
String helpers transform a variable value or a quoted literal. A helper name must be followed by at least one argument to be recognized; quoted literals may contain spaces. Helper output is HTML-escaped in HTML content.
Examples below assume company = MSH Software and jobTitle = senior engineer.
| Operation | Template example | Result |
|---|---|---|
| Uppercase | {upper company} | MSH SOFTWARE |
| Lowercase | {lower company} | msh software |
| Capitalize every word | {capitalize jobTitle} | Senior Engineer |
| Capitalize first letter | {capitalizeFirst jobTitle} | Senior engineer |
| Substring | {substring company 0 3} | MSH |
| Replace | {replace company "Software" "Soft"} | MSH Soft |
| Abbreviate to width | {abbreviate company 8} | MSH S... |
| Remove characters | {cut company " "} | MSHSoftware |
| Fallback when empty | {defaultIfEmpty mobileNumber "n/a"} | n/a when Mobile number is empty |
| Format | {stringFormat "%s at %s" jobTitle company} | senior engineer at MSH Software |
| Strip HTML tags | {stripTags company} | value without tags |
| Word wrap at width | {wordWrap company 5} | value wrapped every 5 characters |
| Slug | {slugify company} | msh-software |
Helpers and conditionals can be combined with the full variable catalog, message variables included:
{#if mobileNumber}Mob: {mobileNumber}{/if}
{#if not subject}(no subject){/if}
Re: {upper subject}
Attachments: {message:attachments:count} ({message:attachments:size:mb} MB)
Iteration
{#each LIST} blocks iterate over message collections. Inside the block the item's fields are
available as tokens, and {else} renders when the list is empty:
{#each message:attachments}
{fileName} ({size} bytes, {contentType})
{else}
no attachments
{/each}
{#each message:headers}{name}: {value}
{/each}
{#each message:recipients}{email} ({type}); {/each}
| List | Item fields |
|---|---|
message:attachments | {fileName}, {size}, {contentType}, {type} |
message:headers | {name}, {value} |
message:recipients (alias message:envelope:recipients) | {email}, {type} (TO / CC / BCC) |
Inside a block, item fields take precedence over variables of the same name. Unknown list names iterate nothing.
Notes
- Unknown variables resolve to an empty string.
- Block tags placed on their own lines leave no blank lines behind; the renderer strips them.
- Variables with modifiers, such as
{message:header:x-msh-id}or{photo:100x60}, work inside blocks exactly as they do outside them.