MSH Software / blog

Signatures That Adapt to the User With the Template Language

A signature template with placeholders works well until the directory is not uniform. Some people have no mobile number, so their signature ends in an empty “Mobile:” line. The research team wants a different closing line than sales. Soon there is one template per department and per exception, and every design change has to be made in all of them. Since version 1.2, MSH Postfix Milter templates can make those decisions themselves.

One template, many users

The template language adds conditions, comparisons and loops to the variables you already use, written with the same single braces. A line wrapped in a condition appears only when the value behind it is set, so the mobile line is simply left out for users who have none:

{firstName} {lastName}{#if mobileNumber} | M: {mobileNumber}{/if}

Comparisons choose between texts. One template can close with a Polish greeting for users whose country is Poland and an English one for everyone else:

{#eq country "Poland"}Pozdrawiam{else}Best regards{/eq}

The same works for naming the R&D team only for the Research department. Conditions can be combined with and, or and not, and chained with {else if} for more than two cases.

Template Preview of a user signature in MSH Postfix Milter, showing the rendered signature of Alice Johnson with her email, phone and mobile numbers, and a list of users to preview

Not only signatures

The same syntax works wherever variables are accepted: subjects, header values, autoreply texts, attachment paths and executable arguments. Loops go through the attachments, headers or recipients of the message, so a notice can list the names and sizes of the files a rule removed, and fall back to other text when there are none.

Safe to experiment

The template preview renders the same syntax with the data of any user you pick, so what you see in the designer is what will be sent. A template with a syntax error is kept as it is, so a mistake never breaks message processing, and the preview shows it before anyone receives it.

Read more in the Template language and Variables documentation.

To learn more visit MSH Postfix Milter website.

More about MSH Postfix Milter

All posts