Page 1 of 1

ZoneMinder 1.36 Email notification problems

Posted: Wed Jun 02, 2021 3:45 pm
by lk777
Ubuntu 20.04 (LXD container)

ZoneMinder 1.36

This is my first installation of ZoneMinder and I started with 1.36
I can't get email notifications working.

Installed ssmtp and configured it to send messages via gmail.
All command line tests succeeded, but ZoneMinder will not send alarm messages.

The filter "List Matches" lists correct events that were supposed to trigger email notifications.
Log shows that email can't be sent because 'Email To" is blank. If I understand it correctly, I am using Email settings (options) so it is not necessary to provide an email address here. When I provide Email To, the log shows "Creating notification email" but nothing has been sent.


What am I doing wrong?

Re: ZoneMinder 1.36 Email notification problems

Posted: Wed Jun 02, 2021 4:38 pm
by bkjaya1952
Please try msmtp instead of ssmtp

https://bkjaya.wordpress.com/2019/10/21 ... ntu-19-04/

There are some differences in Zoneminder 1.36 in the filter.

Copy the contents in EMAIL_BODY cage and paste on the filter at email cage

Note :- Please refer the following link to see the emailing filter of Zoneminder 1.36

https://bkjaya.wordpress.com/2020/12/24 ... ker-image/

Re: ZoneMinder 1.36 Email notification problems

Posted: Wed Jun 02, 2021 5:30 pm
by lk777
Thank you for your recommendations.
I have copied a body and a subject from email settings to the filter and now it works with SSMTP.
Email settings/Filter are a bit confusing though.

Re: ZoneMinder 1.36 Email notification problems

Posted: Thu Sep 14, 2023 7:42 pm
by robfish
I used bkjaya1952's link to set up msmtp (for v1.33.14 on Ubuntu 19.04) so I thought that I would post here how I successfully set it up on my system
vv1.36.33 on Debian 12:-

First you will have to install MSMTP ( If ssmtp , sendmail available , please uninstall completely )
Open the terminal and run

Code: Select all

sudo apt install msmtp
Then create sendmail file which a symlink of msmtp ( at /usr/bin) in /usr/sbin/
Note: before making below symlink , make sure that there is no sendmail file in /usr/bin

Code: Select all

sudo ln -s /usr/bin/msmtp /usr/sbin/sendmail
When zmfilter.pl searchs for /usr/sbin/sendmail , it redirects to msmtp which is the main executable file at /usr/bin/

Now you will have to create a configuration file called msmtprc which contains email hosts ,ports ,certificates ,email details etc at the directory /etc/

Code: Select all

sudo nano /etc/msmtprc
When the empty file is opened, enter the following scripts

Code: Select all

# Set default values for all following accounts.
defaults
auth            on
tls             on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile         ~/.msmtp.log

# Gmail
account         gmail
host            smtp.gmail.com
port            587
from            your gmail address
user            your gmail address
password        your gmail "app" password

# Set a default account
account default : gmail
Exit and save the file
Note: for info on Gmail App passwords see https://support.google.com/mail/answer/185833?hl=en
To add group www-data to the file

Code: Select all

sudo chown root:www-data /etc/msmtprc
Now you can try a test mail on the terminal

Code: Select all

echo "Subject: msmtp test" | msmtp -v an.em@il.address
(replace an.em@il.address with a real address)

Now go to Options/Email on the ZM-Console and set the following:-

OPT_EMAIL ticked
MESSAGE_ADDRESS I do not think this needs to be entered here as it is now entered in the "Filter"
NEW_MAIL_MODULES ticked
EMAIL_HOST localhost
FROM_EMAIL the same address you used in the /etc/msmtprc connfig file
URL e.g. http://host.your.domain/zm/index.php
SSMTP_MAIL ticked
SSMTP_PATH /usr/bin/msmtp

To set up filters you now enter the "Email Body" with what used to be entered in the Options Email "Message_Body"
I used:-
ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% score.

Attach (first) event image with the highest score : %EIM%
Path to the event stream : %EPS%
Path to your ZoneMinder console : %ZP%

Thanks to @bkjaya1952 for creating the base for this "howto"

Re: ZoneMinder 1.36 Email notification problems

Posted: Mon Jun 10, 2024 6:27 am
by huang201
bkjaya1952 wrote: Wed Jun 02, 2021 4:38 pm Please try msmtp instead of ssmtp

https://bkjaya.wordpress.com/2019/10/21 ... ntu-19-04/

There are some differences in Zoneminder 1.36 in the filter.

Copy the contents in EMAIL_BODY cage and paste on the filter at email cage

Note :- Please refer the following link to see the emailing filter of Zoneminder 1.36

https://bkjaya.wordpress.com/2020/12/24 ... ker-image/
Hi Sir, Thank you so much for your instructions on email settings!
I installed zoneMinder 1.37.55 on Debian 12. I followed every step of the instructions in your two blogs to set up email alerts with msmtp. The only difference is I use zoneMinder 1.37 and smtp.gmail.com
I can send out emails with a terminal command line to my receiving email inbox with no issue.
The motion detection filter works, on the ZoneMinder web UI, the log record of the filter shows: "Notification email sent to myusername@gmail.com"
but I do not receive the email.
Therefore, the issue is the filter does not trigger the msmtp to send the email. Instead, it could trigger another smtp app which I don't know.
I have been struggling with this email setup for two days and googled and read a lot of related posts, your blogs are the best.
Could you advise how to debug it?
Your help would be very much appreciated!

Re: ZoneMinder 1.36 Email notification problems

Posted: Mon Jun 10, 2024 6:41 am
by huang201
robfish wrote: Thu Sep 14, 2023 7:42 pm I used bkjaya1952's link to set up msmtp (for v1.33.14 on Ubuntu 19.04) so I thought that I would post here how I successfully set it up on my system
vv1.36.33 on Debian 12:-

First you will have to install MSMTP ( If ssmtp , sendmail available , please uninstall completely )
Open the terminal and run

........

To set up filters you now enter the "Email Body" with what used to be entered in the Options Email "Message_Body"
I used:-
ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% score.

Attach (first) event image with the highest score : %EIM%
Path to the event stream : %EPS%
Path to your ZoneMinder console : %ZP%

Thanks to @bkjaya1952 for creating the base for this "howto"
Hello there,
I found and read your post--I believe it's the most recent and most thorough one about msmtp setup in zoneminder. And I have done almost exactly the same steps except my zm is v1.37, but I failed on the last step:
As I said on the last post above, I installed zoneMinder1.37.55. I can send emails as you can using the command line in my Debian 12 terminal. And when motion is detected the zoneminder filter posts a "Notification email sent to myusername@gmail.com" record on zoneminder web UI log, but I actually do not receive any email for the motion detection alert.
Could you please advise what I can do next?
Any input would be appreciated!

Re: ZoneMinder 1.36 Email notification problems

Posted: Mon Jun 10, 2024 5:32 pm
by mikb
Can you test with a provider other than gmail?

Gmail have some very funny ideas about how email works, and have decided that they don't feel the need to create bounce emails when they don't like something you've done. They just eat the email without trace, without explanation, and without apology.

It's hard enough being 100% sure a regular, manually sent, normal email has got through to gmail users with Gmail's mighty fist of iron ruling over incoming email ... let alone trying to debug ZM sending (or not) automated mails!

You will have to be 100% sure that you have complied with all Google's latest requirements around DKIM, SPF etc. and that your ISP has done the same. Be sure that you're not using an IP address that may have been used by a bad actor before you.

Good luck!