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;
}'