Mail Assure Help

Email Scout Report (ESR) Template Defaults and Variables

The Email Scout Report templates are written using the Jinja templating language. If you are unfamiliar with this, we recommend that you begin by copying and editing an existing template - see Email Scout Report Templates (Preview).

Default/Recommended ESR Templates

The following default templates are available from Reporting > Email Scout Report templates (Preview) (with Features Preview enabled), in the Recommended Templates tab:

  • column
  • row

Column template

Row template

Template Variables

The following variables can be added to the Email Scout Report templates. When the template is applied to a report, the variable content is added.

  • {{ columns }} - Use this variable to choose from the following columns:
Column Variable name
Message ID exim_id
Domain domain
Filtering host host
Timestamp date
Sender sender
Recipient recipient
Sender hostname sender_host
Sender IP sender_ip
Sender location sender_location
Bytes received incoming_size
Bytes sent: outgoing_size
Main class main_class
Sub class sub_class
Extra class extra_class
Error class error_class
From fromh
To toh
CC cch
Subject subjecth
Original Message ID message_id_header
Status status
Delivery date delivery_date
Delivery IP delivery_ip
Delivery hostname delivery_fqdn
Delivery port delivery_port
Delivery data delivery_data
Delivery interface delivery_interface
In archive archive_id
  • {{ objects }} - Log search results list
  • {{ brand }} - Brand name for the domain
  • {{ now }} - Current date and time
  • {{ name }} - Name of the report
  • {{ destination }} - Email address of the report recipient
  • {{ view }} - Generates a link to view message and optionally perform specific actions
  • {{ decode_idna() }} - Converts an IDNA encoded domain to a Unicode representation.
  • {{ country_name() }} - Converts a two-character country code to the country name
  • {{ unsubscribe_link() }} - Generates a link to unsubscribe from the Email Scout Report
  • {{ format_date(datetime or date[, format]) }} - Converts a date or datetime (timestamp) to a user-readable string
  • {{ format_time(datetime[, format]) }} - Converts a datetime (timestamp) to a user-readable string
  • {{ format_timedelta(timediff) }} - Converts a date/time difference to a user-readable string
  • {{ brand_color }} - Adds the brand colour to the report
  • {{ logo_url }} - Adds the Branding logo specified in the Branding Management page to the report.

Look at the existing templates (above) to see how the variables have been applied using Jinja.

Example Email Scout Report (ESR) Template Content

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<!---- Add some basic styling --->

<style>

table {

border-collapse: collapse;

}

td, th {

border: 1px solid grey;

padding: 5px;

}

 

tr:nth-child(even) {

background-color: ivory;

}

 

tr:nth-child(odd) {

background-color: azure;

}

</style>

</head>

 

<body>

<!-- Set the column labels, names and formats -->

{% set column_order = [

("Datetime", "datetime", "date_format"),

("Filtering server", "filtering_host", "decoded"),

("Message ID", "message_id", None),

("Sender IP", "sender_ip", None),

("Sender hostname", "sender_host", "decoded"),

("Sender", "sender", "decoded"),

("Recipient", "recipient", "escaped"),

("From", "from_header", "escaped"),

("To", "to_header", "escaped"),

("CC", "cc_header", "escaped"),

("Subject", "subject_header", None),

("Incoming size", "incoming_size", "size"),

("Outgoing size", "outgoing_size", "size"),

("Delivery date", "delivery_date", "date_format"),

("Destination IP", "destination_ip", None),

("Destination host", "destination_host", "decoded"),

("Destination port", "destination_port", None),

("Status", "status", "status"),

("Classification", "main_class", None),

]

%}

<!--- Here is your header content -->

<div id="header">

<!-- An example of using a data URI to encode images -->

<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gODUK/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxERExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8IAEQgAZAEOAwEiAAIRAQMRAf/EABsAAQADAQEBAQAAAAAAAAAAAAAEBQYBAwIH/8QAGQEBAAMBAQAAAAAAAAAAAAAAAAEEBQID/9oADAMBAAIQAxAAAAH9lAAAAAAAAAAAAAOHQAAAAAAAAAAAAAcqZWezbnfism4GrPm+Vvt5kga1EAAAAZ40LI/RrKehlGsZ7Pn6Cxk80jGe5rGUiG2YiSa6moum1fn2yI2f22YxNH2v4s3QqdFvx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0jguNEoYIo6R308Ya65c2/wCjx/KNjFx6PeNB84G6phhFGlMHnbxu5xlkg3R2afbYUpjcLnEBId2aOVnTebc2OfeBD5wbZrRq6dGnZppjtDjhaUVjZK73iXDSuOg8Ls1hlgIjwmKkJoFaURq8ykupVBA4EXwY3FEAEYTogh8ZvJmAYkRWusRY9mVUo743lA9ZgMNJHnpnbkJq8bN0vzGTYLqrjAAhBFvI+MTSTJAUFog8074muAK0hDs2KefOTxiygevAQLgyQwdg16mO595TuZTviHIPnKS0mU7n+vHp+b2x0sEEVBV5vJiwOuRdCvbZndwxJnbW5+EfBgU8Q2DWpOD8YFiDoZHCdMYIEhpBBPYL85sEZtUQRfO58erNAdsSEUQKcn4cuIcSBvT7PvAUxJ2OAfh+s1U6kjdGzWcvabbLI/v5wrSBGwaQGkvjjJACSG0gB9B+fXyYxgdGmgdwe2K0hVRQ6ZN317Mn+Nf83//Z/>

<p>

<h1>Email Scout Report</h1>

This is the email scout report for {{ destination }}, sent at {{ format_time( now ) }}.

</div>

 

<!-- Here is the report content --->

<p>

<div id="content">

<!-- Create a table to hold the content. Use the column_order array to get the headings for the colums -->

<table>

<thead>

<!--- A for-loop to iterate through the column_order array and get the column label and format for the columns that have been included in the report. -->

{% for label,column,column_format in column_order if column in columns %}

<!--- Use the label from the array as the column heading --->

<th> {{ label }} </th>

{% endfor %}

<!-- Add a column heading for the view message column -->

<th>View message</th>

</thead>

 

<tbody>

<!-- Fill in the table contents by iterating through the objects list -->

{% for object in objects %}

<!--- Create a new row for each object -->

<tr>

<!-- Get the list of column labels and formats from the colum_order array --->

{% for label,column,column_format in column_order if column in columns %}

<!--- Create a new table item for each column -->

<td>

<!-- Insert a blank for null items --->

{% if not object[column] %}

{{ "" }}

<!--- For each column, apply the appopriate format from the column_order array -->

{% elif column_format == "date_format" %}

{{ format_date(object[column]) }} {{ format_time(object[column]) }}

{% elif column_format == "escaped" %}

{{ object.get(column, "")|replace(".", "<span>.</span>"|safe) }}

{% elif column_format == "decoded" %}

{{ decode_idna(object.get(column, ""))|replace(".", "<span>.</span>"|safe) }}

{% elif column_format == "size" %}

{{ object.get(column)|filesizeformat }}

{% elif column_format == "status" %}

{{ object[column]|replace("-", " ")|title }}

{% else %}

{{ object.get(column) }}

{% endif %}

</td>

{% endfor %}

<td>

 

<!--- If the object is quarantined or queued, add a link to allow actions on the object -->

{% if object.get("status", "") == "quarantined" %}

<a href="{{ view(object, ['release', 'release and train', 'remove', 'blacklist sender', 'whitelist sender', 'lock identity']) }}">View quarantined message</a>

{% elif object.get("status", "") == "queued" %}

<a href="{{ view(object, ['cancel delivery', 'add recipient', 'cancel delivery and generate bounce', 'show next delivery attempt', 'retry' ]) }}">View queued message</a>

{% endif %}

</td>

</tr>

{% endfor %}

 

</tbody>

</table>

</div>

<!--- Footer content goes here --->

<div id="footer"><p>

This report was created by the <strong>{{ brand }}</strong> mail protection system.

 

<!-- Include an unsubscribe link for any automatically generated ESRs -->

{% if unsubscribe_link %}

<p>Click here to unsubscribe: <a href='{{ unsubscribe_link() }}'>Unsubscribe</a>

{% endif %}

</div>

</body>

</html>

Example ESR Email Sent