Conditional Email - No Subject

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
kentbrockman
Newbie
Newbie
Posts: 4
Joined: June 20th, 2010, 2:28 pm

Conditional Email - No Subject

Post by kentbrockman »

I'm trying to set up a conditional email notification template so that I only receive emails when files of "tv" category are downloaded.

Here is my custom template:

Code: Select all

##
## 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
<!--#if $cat == "tv" #-->
subject: SABnzbd has <!--#if $status then "completed" else "failed" #--> job $name
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#-->
<!--#end if#-->
I have added the if statement at the top as described in the help.
The template does work, except  the resulting email does not have a subject, which is because the "subject:" value comes after the if statement.
But if I pull the if statement up I end up receiving emails for all downloads.

Does anyone have any ideas how to fix this?

Cheers,
Kent
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Conditional Email - No Subject

Post by shypike »

The end result contains a empty line at the beginning, this is fatal.
(Sorry, that's the way the email protocol works, but we're going to fix that in 0.5.3).
You can remove this by adding "slurp".

Code: Select all

<!--#if $cat == "tv" #--><!--#slurp#-->
subject: SABnzbd has <!--#if $status then "completed" else "failed" #--> job $name
BTW: You also have a double subject line.

I'll change the Wiki instructions.
Last edited by shypike on June 20th, 2010, 4:13 pm, edited 1 time in total.
kentbrockman
Newbie
Newbie
Posts: 4
Joined: June 20th, 2010, 2:28 pm

Re: Conditional Email - No Subject

Post by kentbrockman »

shypike,

Thanks for the quick response.
Your solution works like a charm.

Cheers,
Kent
Post Reply