20.2. Email Templates
20.2.1. Introduction
Email templates are a powerful instrument to customize layout and
content of email messages. Templates are defined as XML files, and are
located in the /opt/savapage/server/custom/template/ directory by
default. Alternative locations can
be configured.
Default templates are present in the SavaPage i18n jars. Therefore,
after a first-time installation the custom template/ directory will
be empty. However, when SavaPage finds a suitable i18n XML file in
the custom directory, that belongs to an
Email Message Type, it will use that template.
You can create i18n variants of template XML files by appending the
locale to the base file name. For example: template_de.html is the
German variant of template.xml.
20.2.2. Email Template Syntax
The base syntax of an Email Template [2] is described by example in the following XML file:
<?xml version= "1.0" encoding= "UTF-8" ?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> ①
<properties>
<!-- $obj.attr$ placeholders are replaced at runtime --> ②
<!-- TEXT --> ③
<entry key="text"><![CDATA[Text with $obj.attr$ placeholders.]]></entry>
<!-- HTML --> ④
<entry key="html"><![CDATA[<b>HTML</b><p>
with $obj.attr$ and other placeholders</p>]]>
</entry>
</properties>
- 1:
DTD of XML persisted
java.util.Propertiesfile.- 2:
Placeholder object attributes are dentified by a
$character at the beginning and the end. Valid objects are defined for each Email Message Type. The global Application Object is valid for all types.- 3:
Content for plain
textmessage body.- 4:
Content for
htmlmessage body.
20.2.2.1. Embedded Images
HTML content may contain Embedded (Inline) Images.
Images are first defined in separated template entries with keys that
have “cid_” prefix. Those keys can then be used as placeholders for
cid scheme values. SavaPage email processor will embed the image
file and replace cid placeholders with a unique Content-ID for the
Embedded (Inline) Image.
Custom image files are referred to by their relative path from the
custom template/ directory. Internal stock images can simply be
referred to by their upper-case identifier, as shown in the table below.
Object.attribute |
Value |
|---|---|
|
SavaPage Icon: 32 x 32 pixels, 705 bytes. |
|
SavaPage Logo with “SavaPage” text at the bottom: 148 x 174 pixels, 5.6 kB. |
The XML snippet below shows how it works:
<entry key="cid_1">SAVAPAGE_ICON</entry> ①
<entry key="cid_2">images/mysite-logo.png</entry> ②
<entry key="html"><![CDATA[
<img src="cid:$cid_1$" alt="$app.name$"> ③
<a href="https://mysite.xyz">
<img alt="mysite.xyz" src="cid:$cid_2$"/> ④
</a>
]]></entry>
- 1:
cid_1holds a stock image.- 2:
cid_2holds the relative path to a custom image file.- 3:
Note that the URL of the image has scheme
cid. SavaPage email processor will embed the image and replace $cid_1$` with a unique Content-ID for the Embedded (Inline) Image with keycid_1.- 4:
The
cid_2image is handled just as itscid_1sibling.
20.2.3. Email Stationary Template
An Email Stationary Template is used by an Email Message Template as container to embed its content in. A stationary is typically used by many Email Messages Types, and thus gives a common look-and-feel to various email output.
A Stationary Template contains the following placeholder objects:
And this is how it looks like:
<?xml version= "1.0" encoding= "UTF-8" ?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<!-- TEXT -->
<entry key="text"><![CDATA[Plain text with $stationary.header$ ①
$stationary.content$ and additional app placeholders]]></entry> ②
<!-- HTML -->
<entry key="html"><![CDATA[HTML with <b>$stationary.header$</b>
<p>$stationary.content$ and additional cid_ and app placeholders</p>]]> ③
</entry>
</properties>
- 1:
$stationary.header$is replaced by theheaderentry of the embedded template.- 2:
$stationary.content$is replaced by thetextentry of the embedded template.- 3:
$stationary.content$is replaced by thehtmlentry of the embedded template.
Note
SavaPage uses its own stationary types. These types can be overwritten. See Email Stationary Types.
20.2.4. Email Message Template
Email Message Templates are used by Email Message Types.
Template and Type are tied by name.
For example: the
JobTicketCompleted
message type will look for the nearest i18n version of a
JobTicketCompleted.xml template file. In this way,
JobTicketCompleted_de.xml will be the perfect match when a German
email message is requested.
Email Message Template adds the entry key “subject” to the syntax.
Optionally, entry keys “stationary” and “header” can be used to
link to an Email Stationary Template.
The syntax is described by example in the following XML file:
<?xml version= "1.0" encoding= "UTF-8" ?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<!-- Email subject --> ①
<entry key="subject">Text with $obj.attr$ placeholders</entry>
<!-- Optional stationary --> ②
<entry key="stationary">EmailStationary</entry>
<entry key="header">Stationary header with placeholders</entry>
<!-- TEXT -->
<entry key="text"><![CDATA[Plain text with placeholders.]]></entry>
<!-- HTML -->
<entry key="html"><![CDATA[<p>HTML with placeholders.</p>]]></entry>
</properties>
- 1:
The
subjecttext of the email.- 2:
The
stationaryvalue (just the template file basename, without the.xmlsuffix) refers toEmailStationary.xml, including i18nEmailStationary_*.xmlvariants. If a stationary is linked this way, theheadervalue is injected into thestationary.headerplaceholder of the target stationary, and thetextandhtmlvalues are injected into thestationary.contentplaceholder of their counterpart stationary entry.
20.2.5. Email Placeholders Objects
Placeholder Objects are used in Email Stationary, and in Email Message Templates tied to Email Messages Types.
20.2.5.1. Stationary
Object uniquely used by Email Stationary Template.
Object.attribute |
Value |
|---|---|
|
The |
|
The |
20.2.5.2. Application
A global object with SavaPage application attributes. This object can be used in any Email Message Type context.
Object.attribute |
Value |
|---|---|
|
Application name: “SavaPage” |
|
Formatted name and version, like: |
|
Formatted name, version and build, like: |
|
Short slogan describing the application: |
20.2.5.3. Ticket
A Print Job Ticket. See Job Tickets Web App.
Object.attribute |
Value |
|---|---|
|
Ticket number. |
|
Document name. |
|
Name of the Job Ticket Operator. |
|
The return message to Job Ticket Creator (optional). |
20.2.5.4. User
A User as Person.
Object.attribute |
Value |
|---|---|
|
The full name of the user. |
20.2.5.5. User Registration
Object |
Value |
|---|---|
|
User Name. |
|
User Full Name. |
|
Verification URL. |
20.2.6. Email Stationary Types
SavaPage uses its own Email Stationary Types. As the table below
shows, currently there is just one type in use. You can use this type in
your own custom Email Message Template files.
Or, you can override this type by creating your own EmailStationary.xml i18n
variants in the custom template/ directory.
Name |
Scope |
|---|---|
|
All Email messages |
20.2.7. Email Message Types
The sections below describe email message types that can be customized. The list is limited for now, but will grow as more messages are refactored for this purpose.
Note
The global Application Object is valid for each message type.
20.2.7.1. JobTicketCanceled Email
Email sent when a Job Ticket is canceled. See Job Ticket Configuration Properties.
The following placeholder objects apply:
Object |
Role |
|---|---|
|
Canceled Job Ticket. |
|
20.2.7.2. JobTicketCompleted Email
Email sent when a Job Ticket is completed successfully. See Job Ticket Configuration Properties.
The following placeholder objects apply:
Object |
Role |
|---|---|
|
Completed Job Ticket. |
|
20.2.7.3. UserRegVerification
Email sent to verify User Self Registration.
The following placeholder objects apply:
Object |
Role |
|---|---|
|
User Self Registration. |
20.2.8. Custom Template Locations
Custom templates are located in the
/opt/savapage/server/custom/template/ directory. Sub-locations
can be defined for different template groups. These sub-locations can
then be activated for different applications, with the following
configuration properties:
Configuration property |
Description |
|---|---|
custom.template.home |
Home location of all template files, relative to the default location.
For example: a value of |
custom.template.home.mail |
Home location of Email template files, relative to the default location.
For example: a value of |
See Config Editor on how to set these items.