ESR Templates

Use the Email Scout Report templates feature to customise the format of your reports. This can be accessed at the Admin Level from Reporting > ESR templates.

This page contains the following tabs:

  • Templates - Lists all custom templates (and any copies made from the Recommended Templates tab). Using the menu to the left of each template listed, you can create, edit, remove and copy templates. You can also view all incoming and outgoing Email Scout Reports that use each template
  • Recommended Templates - Contains the default templates available to all users. Using the menu to the left of each template listed here, you can copy each template and view all incoming and outgoing Email Scout Reports that use each template. Copying a template in this tab pastes a copy into the Templates tab:
    • Column based - suitable for reports containing a small number of results
    • Row based - suitable for reports with a large number of results

    Use the Recommended Templates to base your own custom ones on. For information on default template content, see Template Defaults and Variables.

  • Automatic Email Scout Report Activation Messages - Contains all templates created for the Email Scout Report activation messages (sent when an ESR is scheduled to be sent to a recipient). You can add a new activation message template in this tab (by clicking the + Add activation message template link at the top of the page). In this tab, you can also copy an existing template - the copy is listed here too

Create Email Scout Report Template

The 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. If you have used templates before, and feel confident in creating a new template, this can also be done by following these instructions. For information on the default templates available, see Template Defaults and Variables.

Create a Copy of an Existing Template

  1. Login to SpamExperts as an Admin Level user
  2. In the Admin Level Control Panel select Reporting > ESR Templates
  3. You can copy a template from the Templates or Recommended Templates tabs by selecting Copy from the menu to the left of the template you want to copy:

  4. In the Copy Email Scout Report template dialog, replace the copied template name with a new name in the Template name field
  5. In the Admin field enter the Admin user for which this template applies
  6. Use the HTML and Plain tabs to add your template format
    • HTML - content here will be displayed in the text/html version of the report which is the default for most email clients
    • Plain - content here will be displayed in the text/plain version of the report. Older or limited email clients will use this view
  7. You can add variables from the set listed in the Variables reference panel to the right of the page. For more information on how to use the variables, refer to the examples given in the list or see Template Variables
  8. The following shows an example HTML template containing a selection of variables - and comments describing the content used:

    <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/RrKehlGsZ7Pn6Cxk80jGe5rGUiG2YiSa6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isVI0Mhqqy27riulkVA0GnTXvgEAR0jguNEoYIo6R308Ya65c2/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 appropriate 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', 'block list sender', 'allow list 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>

  9. Click Save
  10. The new template is placed in the Templates tab irrespective of the tab from which it was copied
  11. The following shows the Email Scout Report email using the example content shown above:

If you are familiar with the Jinja templating language, you can create a completely new template by clicking on the + Add template link at the top of the page and adding your own content.

Create a New Template

  1. Login to SpamExperts as an Admin Level user
  2. In the Admin Level Control Panel select Reporting > ESR Templates
  3. You can create a new template in the Templates tab by selecting Add Template
  4. The Add Email Scout Report template dialog opens
  5. Give the template a name in the Template name field
  6. Slide the toggle to Include standard branding if you require this to be enabled
  7. If Branding is enabled, the option for Include Standard Branding will be displayed in the add wizard. If Include Standard Branding is enabled, the brand logo or name will be added to the top of the generated message. If this is disabled, the message will be white-labeled, or custom styled if styling is added within the template.

  8. In the Admin field enter or select the Admin user from the dropdown for which this template applies
  9. Select the language that the template is in from the Language field
  10. Use the HTML and Plain tabs to add your template format
    • HTML- content here will be displayed in the text/html version of the report which is the default for most email clients
    • Plain- content here will be displayed in the text/plain version of the report. Older or limited email clients will use this view.
  11. You can add variables from the set listed in the Variables reference panel to the right of the page. For more information on how to use the variables, refer to the examples given in the list or see Template Variables
  12. Use the Preview tab to view what the report will look like when applied to an existing Email Scout Report 
    1. Select the report to preview from the Email Scout Report field
    2. Choose the Number of records to view:
      • Up to 2 records
      • Up to 50 records
  13. Click Save. The new template is placed in the Templates tab

Edit Existing Templates

To edit an existing report:

  1. Go to ReportingESR TemplatesTemplates
  2. Find the template you wish to edit
  3. Click the dropdown arrow to the left of the template name and select Edit
  4. Make any changes to the report as required
  5. If Branding is enabled, the option for Include Standard Branding will be displayed in the edit wizard. If Include Standard Branding is enabled, the brand logo or name will be added to the top of the generated message. If this is disabled, the message will be white-labeled, or custom styled if styling is added within the template.

  6. Save the changes made

View Incoming/Outgoing Reports from a Particular Template

You can find out what Email Scout Reports are using any of your templates:

  1. Login to SpamExperts as an Admin Level user
  2. Navigate to Reporting > ESR Tempplates
  3. In the Templates or Recommended Templates tab, click on Show Results to display all existing templates
  4. From the dropdown to the left of a template, select Incoming reports using this template or Outgoing reports using this template:
  5. The Email Scout Reports page is displayed showing search results for the Template equals <templatename> query.

Choose the default Automatic Email Scout Report Activation Messages

In the Automatic Email Scout Report Activation Messages section you can select the activation email that is sent when Email Scout Reports are created. For example, set the default for a different language or welcome new mailboxes using content specific for their service.

To choose the default template.

  1. Go to ReportingESR TemplatesAutomatic Email Scout Report Activation Messages
  2. Click the drop-down against the target template
  3. Select Make Default

As a visual indicator a default template that is marked with a tick.