Simple Email Notification?

Forum for questions and support relating to the 1.25.x releases only.
Post Reply
nuvious
Posts: 4
Joined: Wed Feb 08, 2012 9:37 am

Simple Email Notification?

Post by nuvious » Wed Feb 08, 2012 9:41 am

I want to set up an email notification whenever a new event occurs, but I've found the documentation for filters to be very confusing. Can someone post a simple tutorial (either here or in another post and link to it here) on how to set up a filter and an email notification whenever a new event is registered?

nuvious
Posts: 4
Joined: Wed Feb 08, 2012 9:37 am

Re: Simple Email Notification?

Post by nuvious » Sun Feb 12, 2012 10:52 pm

Okay, so I think I figured out why the simple email settings aren't working on my ZoneMinder installation. I went to the logs and found this:

Code: Select all

02/12/2012 17:48:22.993551 zmfilter[20345].INF [Creating notification email]
02/12/2012 17:48:22.994980 zmfilter[20345].INF [Sending notification email 'ZoneMinder: Alarm - Monitor-7-68 (33 - 14 29)']
02/12/2012 17:48:23.005264 zmfilter[20345].INF [Creating notification email]
02/12/2012 17:48:23.006794 zmfilter[20345].INF [Sending notification email 'ZoneMinder: Alarm - Monitor-7-69 (18 - 8 24)']
02/12/2012 17:48:23.016994 zmfilter[20345].INF [Creating notification email]
02/12/2012 17:48:23.018351 zmfilter[20345].INF [Sending notification email 'ZoneMinder: Alarm - Monitor-7-70 (18 - 9 34)']
02/12/2012 17:48:23.028595 zmfilter[20345].INF [Creating notification email]
02/12/2012 17:48:23.030089 zmfilter[20345].INF [Sending notification email 'ZoneMinder: Alarm - Monitor-7-71 (10 - 5 14)']
I noticed in zmfilter.pl, that there were more debug lines that would signal that the email had sent properly but were not being so I added some code to get more detailed output and got the following:

Code: Select all

02/12/12 17:50:53.457866 zmfilter[6927].INF [Creating notification email]
02/12/12 17:50:53.459138 zmfilter[6927].INF [Sending notification email 'ZoneMinder: Alarm - Monitor-7-71 (10 - 5 14)']
02/12/12 17:50:53.460039 zmfilter[6927].INF [New Mail Module]
02/12/12 17:50:53.461240 zmfilter[6927].INF [Adding Text]
02/12/12 17:50:53.462243 zmfilter[6927].INF [Adding Attachments]
02/12/12 17:50:53.462770 zmfilter[6927].INF [Sending...]
02/12/12 17:50:53.471051 zmfilter[6927].INF [Can't send email: SMTP mail() command failed:
4.3.0 Temporary system failure. Please try again later.]
Any ideas on how to fix this?

PacoLM
Posts: 970
Joined: Wed Dec 02, 2009 9:55 pm
Location: Spain

Re: Simple Email Notification?

Post by PacoLM » Mon Feb 13, 2012 5:13 am

Do you have postfix installed?

mini-ITX system (4 IPCams - Ubuntu20.04 - ZM1.34.15)
TelegramBot

nuvious
Posts: 4
Joined: Wed Feb 08, 2012 9:37 am

Re: Simple Email Notification?

Post by nuvious » Mon Feb 13, 2012 8:49 am

Installing postfix doesn't help, have tried that. Zoneminder has it's own smtp server installed in the ubuntu package. I've confirmed this via telnet. Even if you install postfix, Zoneminder's smtp server has control over port 25.

PacoLM
Posts: 970
Joined: Wed Dec 02, 2009 9:55 pm
Location: Spain

Re: Simple Email Notification?

Post by PacoLM » Mon Feb 13, 2012 2:32 pm

Then, remove this package and use postfix...

mini-ITX system (4 IPCams - Ubuntu20.04 - ZM1.34.15)
TelegramBot

nuvious
Posts: 4
Joined: Wed Feb 08, 2012 9:37 am

Re: Simple Email Notification?

Post by nuvious » Tue Feb 14, 2012 12:08 am

Did a fresh install of Zoneminder, postfix and still couldn't get it working. Re-imaged the system and started from scratch one more time because I couldn't be believe that installing postfix wouldn't resolve my issue. The re-image worked and I'm still dumbfounded as to what I had done to the previous image to break Zoneminder's ability to use postfix. Thanks for your replies.

koolb
Posts: 14
Joined: Tue Oct 04, 2011 3:30 am

Re: Simple Email Notification?

Post by koolb » Sun Feb 19, 2012 2:36 am

Hey I have some script that checks for motion events. Here's a version I use but I had to base my auth on something more specific to my needs).
I had to install sendmail and fuss with the /etc/mail/submit.mc:
define(`SMART_HOST', `myisp.smtpserver.com')dnl
MASQUERADE_AS(`mydns.dyndns.org')dnl

which added the following entries to the submit.cf after a make:

DSmyisp.smtpserver.com
DMmydns.dyndns.org

Note that you dont need sendmail running at all if you are only outbounding messages.
Seems to send about 20-30 seconds after an event starts.

#!/bin/bash
# watchcam script v1.0 - Author koolb@hotmail.com
# Copyright Dec 2011
#
# repeatedly watches zmu -l for changes in state for the monitors:
# Id Func State TrgState LastImgTim RdIdx WrIdx LastEvt FrmRate
# 1 3 0 0 1324176081.57 65 65 15505 4.25
# 3 3 0 0 1324176081.65 57 57 15416 5.05
# 4 3 0 0 1324176081.73 1 1 15506 4.30

export APP="Cam Watch"
export RCPT="myemail@hotmail.com"
sbmail()
{
subj=$1
body="${2-$(date)}"
echo -e "$body\n\n" | mail -s "$APP: $subj" $RCPT
}
sbmail Starting
trap "sbmail Ending" HUP ABRT TERM QUIT EXIT
while sudo zmu -l -A $(cat /mysecret/auth)
do usleep 80000
done | perl -ne 'sub smail {
my ($subj, $body, $le) = @_;
my $bodyfn="/tmp/ca.$$";
my $loc = sprintf("$httpfmt\n\n\n", $le);
open(BODY, ">$bodyfn") || die "Cant open email file $bodyfn: $!";
print BODY "$body\n$loc";
close(BODY);
system("mail -s \"$subj\" " . $ENV{"RCPT"} ." < $bodyfn");
print "\n$subj";
}
BEGIN {
@monLE = (0, 0, 0, 0, 0);
@monSt = (0, 0, 0, 0, 0);
$httpfmt=$ENV{"MYZMURI"} . "/index.php?view=event&eid=%d";
}{
($id, $fn, $st, $trig, $lastImgDt, $ri, $wi, $le, $rt) = split;
next if $id == 0;

smail("Monitor $id: Event $le Started at " . localtime,
"$changed from " . $monLE[$id] . " @ " . localtime() ."\n", $le)
if $monLE[$id] ne $le && $st > 0;

smail("Monitor $id: Event $le Ended at " . localtime, "Ended", $le)
if $monSt[$id] ne $st && $st == 0;

$monSt[$id] = $st;
$monLE[$id] = $le;
}'

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests