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
$from Sender
$status Job status: True for success
$name Name of the job
$msgid Newzbin report number (meybe empty)
$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

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 should hard-code the recipient(s) in the template and not use the $to variable.

Standard template

Below is the standard template, called email.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, not the slurp command, this removes unwanted line endings in the for-loops.

##
## 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
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 "(from $msgid)" else ""#-->
<!--#else#-->
SABnzbd has failed to download '$name' <!--#if $msgid then "(from $msgid)" else ""#-->
<!--#end if#-->
Finished at $end_time
Downloaded $size

Results of the job:
<!--#for $stage in $output #-->
Stage $stage['name'] <!--#slurp#-->
<!--#for $action in $stage['actions']#-->
    $action : $stage['actions'][$action] <!--#slurp#-->
<!--#end for#-->
<!--#end for#-->
<!--#if $script #-->
Output from user script "$script":
$script_output
<!--#end if#-->
Enjoy!
page_revision: 3, last_edited: 1212314667|%e %b %Y, %H:%M %Z (%O ago)
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License