Email Templates

SABnzbd can send a notification email on completion of a download job.

There is a default format, but you can format your own email using a template.
The formatting language used, is Cheetah. This is also used to create the web interface of SABnzbd.
You need to make yourself familiar with this template language.
Please, refer to the Cheetah home page and more specific its User Guide.

SABnzbd makes these variables available for use in the email:

$to One or more recipients. Read footnote1
$from Sender
$status Job status: True for success
$name Name of the job
$msgid Indexer's report number (if supported)
$end_time Time of job completion
$size Size of the job, includes K/M/G postfix
$output Output of the post-processing = Dictionary of stages
name Name of the stage
actions Results of the stage
$script Script name (empty if no script has run)
$script_output Output of the script
$cat The category of the job

You can create one or more of your own templates. In the Config->Folders page you can specify a folder for the templates.
SABnzbd will look for files ending with .tmpl and will send an email message for every template.
If you want to use different email formats based on the email recipient, you can use conditional formatting (see example below).
Release 0.6.0+ uses two different kinds of templates. "email-*.tmpl" will be used for normal notifications and "rss-*.tmpl" will be used for RSS notifications. Release 0.7.0+ will also have a "badfetch-*tmpl" files, used to report failed URL-based NZB retrievals.

Standard template

WARNING: do not modify the standard templates, but make a copy in your own template folder.
If you modify the standard templates, they will be lost when uninstalling or when upgrading to a new SABnzbd release.

Below is the standard template, called email-us-en.tmpl, which is located in the program folder of SABnzbd.
In the template whitespace and line endings are significant.
Note the empty line between the headers and the actual message. This is an essential element of the email protocol.
Also, note the slurp command, this removes unwanted line endings in the for-loops.

#encoding utf-8
##
## Default Email template for SABnzbd
## This a Cheetah template
## Documentation: http://sabnzbd.wikidot.com/email-templates
##
## Newlines and whitespace are significant!
##
## These are the email headers
To: $to
From: $from
Date: $date
Subject: SABnzbd has <!--#if $status then "completed" else "failed" #--> job $name
X-priority: 5
X-MS-priority: 5
## After this comes the body, the empty line is required!

Hi,
<!--#if $status #-->
SABnzbd has downloaded "$name" <!--#if $msgid=="" then "" else "(newzbin #" + $msgid + ")"#-->
<!--#else#-->
SABnzbd has failed to download "$name" <!--#if $msgid=="" then "" else "(newzbin #" + $msgid + ")"#-->
<!--#end if#-->
Finished at $end_time
Downloaded $size

Results of the job:
<!--#for $stage in $stages #-->
Stage $stage <!--#slurp#-->
<!--#for $result in $stages[$stage]#-->
    $result <!--#slurp#-->
<!--#end for#-->
<!--#end for#-->
<!--#if $script!="" #-->
Output from user script "$script" (Exit code = $script_ret):
$script_output
<!--#end if#-->
<!--#if $status #-->
Enjoy!
<!--#else#-->
Sorry!
<!--#end if#-->

Languages

The email template is available in 5 languages. Given the UI language, the right template will be picked.
Note that when you have your own email template folder, SABnzbd does not support multiple languages.
It will just process all the templates in the folder, thereby assuming that you will write your templates
in the desired language anyway.

Conditional emails

Should you want to make a conditional template, you should place your test before any of the fields.
When the end result is an empty email, SABnzbd will not send it.
A very simplified example:

#encoding utf-8
<!--#if $cat == "video" #--><!--#slurp#-->
To: $to
From: $from
Date: $date
Subject: SABnzbd has <!--#if $status then "completed" else "failed" #--> job $name
X-priority: 5
X-MS-priority: 5
## After this comes the body, the empty line is required!

Hi,
rest of the message
<!--#end if#-->
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License