Problem with Email Notification.

Support and queries relating to all previous versions of ZoneMinder
Locked
p_thrill
Posts: 13
Joined: Tue Jul 06, 2004 3:39 pm

Problem with Email Notification.

Post by p_thrill »

Hi, first of all - Totally AMAZING software!
I'm having difficulty sending out email notifications. I have increased the VERBOSE in the zmfilter.pl file -> 1 and the following gets written to the zmfilter.log file...

Scanning for events
Creating notification email
Sending notification email 'ZM: !ALARM! - Basement id:2004-07-12 19:22:16 at 3431'
Attaching 'Basement/3431/006-capture.jpg
Attaching 'Basement/3431/044-capture.jpg
Attaching 'Basement/3431/Event-3431.mpg

... 1) but I have no trace of the email; nothing gets sent out via smtp or sendmail. I have other scripts that use sendmail and work fine.
... 2) I've specified to send only the nth image, why does it mention that it is attaching the .mpg?

Thanks.
lorenzo
Posts: 6
Joined: Thu Apr 15, 2004 1:47 pm
Location: france

Problem with Email Notification.

Post by lorenzo »

May be ths already post could help you :
Posted: Thu Apr 15, 2004 2:58 pm Post subject: zoneMinder 1.19 and mail alarm
easy to find with a search on postfix

the answer was :
This can be fixed by editing scripts/zmfilter.pl begin at line 600 by commenting that one out and adding the 3 lines below

#$mail->smtpsend();
open MAIL, "| /usr/lib/sendmail -t -oi -oem -f ".ZM_FROM_EMAIL or die "open: $!";
$mail->print(\*MAIL);
close MAIL;
seb
Posts: 14
Joined: Wed Aug 25, 2004 7:27 am
Location: Belgium

Post by seb »

Hi

I'm having problems with notification through an external SMTP server..
Actually, my residential IP is mostly banned for delivery on every servers so I can't use sendmail..

I have chosen SMTP instead of sendmail and the mail notification keeps going in the sendmail queue..

[root@serveur](1113)# mq
/var/spool/mqueue (1 request)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
i7U8to65003119 223474 Mon Aug 30 10:55 <apache@xxx.dyndns.org>
(Deferred: 451 http://dsbl.org/listing?ip=xxx.xxx.xxx.xxx)
<seb@xxx.be>
Total requests: 1


I don't see any trace of ZM_EMAIL_METHOD in zmfilter.pl

I tried lorenzo's fix but it just keeps trying with sendmail..

Code: Select all

sub sendEmail
{
        my $filter = shift;
        my $event = shift;

        if ( !ZM_FROM_EMAIL )
        {
                warn( "No 'from' email address defined, not sending email" );
                return;
        }
        if ( !ZM_EMAIL_ADDRESS )
        {
                warn( "No email address defined, not sending email" );
                return;
        }

        print( "Creating notification email\n" );

        my $subject = substituteTags( $email_subject, $filter, $event );
        my @attachments;
        my $body = substituteTags( $email_body, $filter, $event, \@attachments );

        print( "Sending notification email '$subject'\n" );
        print( "$body\n" ) if ( VERBOSE );

        eval
        {
                my $mail = MIME::Entity->build(
                        From=>ZM_FROM_EMAIL,
                        To=>ZM_EMAIL_ADDRESS,
                        Subject=>$subject,
                        Data=>$body
                );

                foreach my $attachment ( @attachments )
                {
                        print( "Attaching '$attachment->{path}\n" );
                        $mail->attach(
                                Path=>$attachment->{path},
                                Type=>$attachment->{type},
                                Encoding=>"base64"
                        );
                }
                $mail->smtpsend();
        };
        if ( $@ )
        {
                warn( "Can't send email: $@" );
                return();
        }
        my $sql = "update Events set Emailed = 1 where Id = ?";
        my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
        my $res = $sth->execute( $event->{Id} ) or die( "Can't execute '$sql': ".$sth->errstr() );
}
This is zmfilter.log output :

Code: Select all

Archiving event 680
Creating notification email
Sending notification email 'ZoneMinder: Alarm - Bureau-680 (86 - 44 2)'
Attaching 'Bureau/680/011-capture.jpg
Attaching 'Bureau/680/Event-680.mpg
Archiving event 680
Nothing particular in zmdc.log..

Thanks in advance,
Seb
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Hi Seb,

Lorenzo's change needs to be made in more than one place, in case you missed one. And you may need to make it in zmfilter.pl.z if you are rerunning zmconfig.pl otherwise any changes you make to zmfilter.pl will be overwritten.

Given this, does it still not work?

Phil,
apbran
Posts: 3
Joined: Sat Oct 11, 2003 6:21 am

Post by apbran »

I've been looking at the smtpsend() option since changing from a machine running a local sendmail to one which doesn't. From my searching the function needs to know where the smtp server is and zmfilter.pl doesn't appear to tell it.

I have got it working by putting
$ENV{'SMTPHOSTS'}= "hostname";
in /usr/local/bin/zmfilter.pl

In the options -> email screen you can set ZM_EMAIL_HOST but I can't find a reference to this again in the files in /usr/local/bin
User avatar
johabba
Posts: 26
Joined: Mon Jan 24, 2005 11:01 am

Re: Problem with Email Notification.

Post by johabba »

lorenzo wrote:May be ths already post could help you :
Posted: Thu Apr 15, 2004 2:58 pm Post subject: zoneMinder 1.19 and mail alarm
easy to find with a search on postfix

the answer was :
This can be fixed by editing scripts/zmfilter.pl begin at line 600 by commenting that one out and adding the 3 lines below

#$mail->smtpsend();
open MAIL, "| /usr/lib/sendmail -t -oi -oem -f ".ZM_FROM_EMAIL or die "open: $!";
$mail->print(\*MAIL);
close MAIL;
I made this change for both instances of "$mail->smtpsend();" in /usr/local/bin/zmfilter.pl and mail works if I change the Email setting to "sendmail"

My setup:

Gentoo Linux 2004.3
Linux 2.6.10-ck4
Zoneminder 1.20 (not the ebuild)
ssmtp-2.60.9
perl-5.8.5

I also tried to set SMTPHOSTS as described in the other post (i just copied and pasted), but no matter what or how I set smtp, ZM tries to us smtp on some strange IP address:

204.87.241.66 (not me or my smtp host):

Code: Select all

johaBBa@ICU bin $ telnet 204.87.241.66 25
Trying 204.87.241.66...
Connected to 204.87.241.66.
Escape character is '^]'.
220 frisco.gwpc.org Microsoft ESMTP MAIL Service, Version: 5.0.2195.6713 ready at  Mon, 24 Jan 2005 04:47:15 -0600
^]close
It would be nice if the smtp send worked, but this fix gets the job done.

Thanks!
Locked