Page 1 of 1

Email Template Problem

Posted: March 23rd, 2010, 8:22 am
by BitAddict
First of all, Hi everyone - long time lurker, first time poster!

I have a bit of a problem with SABnzbd+ 0.5.0.

Particularly, what I would like to do is send two email notifications on completion of downloads etc.

So what I've done is filled in my details in the web interface under Config>Email.
I've then set up two template files, and configured SABnzbd+ to look in the right folder under Config>Email
In the template files, I've replaced the $to with the email address I'd like the notification to go to.

The first template works perfectly; and sends a notification to the correct email address specified instead of $to.
The second template is being sent to the same address as the first - despite there being a completely different address!

Interestingly, while both emails go to the same address, the second email actually says "To:secondemailaddress" in my inbox, but when I examine the header of the email, obviously it has the first email address (as clearly otherwise it would end up in the correct inbox!)

Coincidentally, the address in the first template is the same as the one specified under Config>Email>Email Recipient.

So what I think is happening, is that despite there being two tmpl files configured with separate email addresses instead of $to, the program is using the one specified under Config>Email>Email Recipient.

I tried deleting the recipient in the web interface, but it won't let me. I can delete everything, but it won't work unless I fill all fields in again; and if I only delete the recipient, it won't delete it.

Re: Email Template Problem

Posted: March 23rd, 2010, 8:54 am
by BitAddict
Here's a screen grab of config>Email

Image
First Tmpl wrote: #
## 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: x@x.com
from: $from
date: $date
subject: TV Series: $name
X-priority: 5
X-MS-priority: 5
## After this comes the body, the empty line is required!

Hi x,

There are new TV Series on your HTPC: "$name"

SABnzbd has failed to download "$name"

Finished at $end_time
Downloaded $size

Results of the job:

Stage $stage

    $result



Output from user script "$script" (Exit code = $script_ret):
$script_output


Enjoy!

Sorry!
Second Tmpl --> Still goes to x@x.com!!! wrote: #
## 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: y@y.com
from: $from
date: $date
subject: TV Series: $name
X-priority: 5
X-MS-priority: 5
## After this comes the body, the empty line is required!

Hi y,

There are new TV Series on your HTPC: "$name"

SABnzbd has failed to download "$name"

Finished at $end_time
Downloaded $size

Results of the job:

Stage $stage

    $result



Output from user script "$script" (Exit code = $script_ret):
$script_output


Enjoy!

Sorry!

Re: Email Template Problem

Posted: March 23rd, 2010, 9:12 am
by shypike
Yes, it looks like the mail module ignores the the "to" field in the template.
and instead uses the "to" from the Config->Email page.
A bug therefore.
I'll schedule a fix for 0.5.1.
(Details, see: https://bugs.launchpad.net/sabnzbd/+bug/545110)

A possible work-around is to setup selective forwarding in your email account.
(Easy when you have Google mail).

Re: Email Template Problem

Posted: March 23rd, 2010, 9:18 am
by BitAddict
Wow, thanks for the fast reply :)
Yep, happy to set up mail forwarding on my server, that's no problem - I was just going to individualise the emails a bit :)

Still - absolutely awesome program. Just made a donation: 9TB16184KB2035407.  ;)

Re: Email Template Problem

Posted: March 23rd, 2010, 4:59 pm
by shypike
With 0.5.1 you will be able to use "individualized" emails.
Just set up a list of recipients in Config->Email, for example:
  john@gmail.com, marie@gmail.com

Then  you make a template like this:

john.tmpl:

Code: Select all

<!--#if $to == "john@gmail.com" #-->
   the usual template
<!--#end if#-->
Make sure that the "if" is the very first line and the "end if" the very last line.
If a template delivers an empty file, it will not be sent.

Thanks for your donation!
It's a bit over the top "mate". We'll drink to your health.