How to resolve e- mailing problem in Zoneminder when using msmtp with gmail

Please refer the procedure at the link below to install masmatp on Ubuntu and to use with Zoneminder

How to use MSMTP as email software in Zoneminder (v1.33.14.) on Ubuntu 19.04

After 30 may 2022 , It has been observed that the sending e – mail alerts of motion detection events are not working for the host smtp.gmail.com .

The error message found in the Zoneminder logs is given in the figure below

Figure:- 1 ZM Error log

After a thorough investigation , it has found the google is not allowing less secure apps to be used with gmail accounts . Please refer the figure below

Figure:- 2 Google notice on Less secure apps

Therefore , we have to drop using a gmail accounts in sending e-mail alerts .

It has found aol mail can be used successfully for sending e- mail alerts .

First you will have to open an aol mail account and login . Then generate an app password for msmtprc as follows.

After login to aol mail , go to Options at the right > Account info

Then go to Account Security at the left corner > Other ways to sign in > App password

Then generate app password for msmtp and keep it for use in msmtprc file.

Using the text editor make a file named msmtprc by including the following codes

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

# aol
account aolmail
host smtp.aol.com
port 587
from youraolmail@aol.com
user youraolmail@aol.com
password generated app password

# Set a default account
account default : aolmail

Figure:- 3 msmtprc file

Then copy the file to /etc/msmtprc as follows

sudo cp msmtprc /etc/msmtprc

Then open the zoneminder panel >Options>email and fill the cages accordingly

Then create filter with the conditions and save and activate as shown in the at the top of this post.

Figure :- 4 email alerts using smtp.aol.com

Now you can see the Zonminder is sending e- mail alerts of motion detection events in the figure 4.

How to Install ZoneMinder master 1.37.16-focal. on UBUNTU focal

It has been noticed that the latest Zomeminder master 1.37.16 focal has some problems with mysql-server 8 .

The mariadb-server works nicely with Zomeminder master 1.37.16.

Therefore mariadb-server is used instead of mysql8 in this tutorial

Installation of mariadb-server & Zoneminder

add-apt-repository ppa:iconnor/zoneminder-master

apt update

apt -y install mariadb-server

apt -y install zoneminder 

apt -y install msmtp tzdata

/etc/init.d/mysql start

Configuring Mysql

mysql -uroot --password=""< /usr/share/zoneminder/db/zm_create.sql 2>/dev/null

mysql -e "ALTER USER 'zmuser'@localhost IDENTIFIED BY 'zmpass';"

mysql -e "GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;"

mysql -e "FLUSH PRIVILEGES ;"

mysqladmin -uroot --password="" reload 2>/dev/null

apt -y install gnupg msmtp tzdata

Configuring Zoneminder

chmod 740 /etc/zm/zm.conf
    
chown root:www-data /etc/zm/zm.conf 

adduser www-data video 

a2enmod cgi

a2enconf zoneminder

a2enmod rewrite

a2enmod headers

a2enmod expires

Starting Zoneminder and apache


systemctl enable zoneminder

service zoneminder start

service apache2 reload
ln -s /usr/bin/msmtp /usr/sbin/sendmail
Open zoneminder web console (http://localhost/zm/)
Figure:-1 Zoneminder Console with USB camera monitor

Note:-

For a docker image Please refer the following link bkjaya1952/zoneminder-master-docker-latest

How to Install ZoneMinder-1.36.0-focal1. on UBUNTU 21.04 ‘Hirsute Hippo’

Installation of Zoneminder

To install Zoneminder v1.36.0-focal1. (stable)Please refer Connor’s web site Open the terminal and run following commands.

sudo su

sudo add-apt-repository ppa:iconnor/zoneminder-1.36

sudo apt-get update

apt install zoneminder

Configuring Mysql

/etc/init.d/mysql start

mysql -e "drop database zm;"

mysql -uroot --password=""< /usr/share/zoneminder/db/zm_create.sql 2>/dev/null

mysql -e "ALTER USER 'zmuser'@localhost IDENTIFIED BY 'zmpass';"

mysql -e "GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;"

mysql -e "FLUSH PRIVILEGES ;"

Configuring Zoneminder

chmod 740 /etc/zm/zm.conf

chown root:www-data /etc/zm/zm.conf 

adduser www-data video

a2enmod cgi 

a2enconf zoneminder

a2enmod rewrite 

a2enmod headers 

a2enmod expires 

Starting Zoneminder and apache

systemctl enable zoneminder

service zoneminder start

service apache2 reload

Open zoneminder web console (http://localhost/zm/)

Figure:-1 Zoneminder Console with USB camera monitor

Figure:-2 e-mailing motion detection events

How to install Zoneminder-1.36-focal1, on UBUNTU 20.04 LTS ( Focal Fossa) Using a Docker image

In this tutorial ,we are going to use “Docker: Enterprise Container Platform”  (docker.io) on Ubuntu 20.04 LTS ( Focal Fossa)

First

Installation of Docker on Ubuntu 20.04 LTS ( Focal Fossa )

On the Ubuntu terminal

sudo apt install docker.io

zoneminder-1.36 ,docker images with php 7.4 ,Mysql 8 & MSMTP

This image has been created on ubuntu:focal with zoneminder-1.36-focal1

To pull the Repository from the Docker Hub please refer the following link

https://hub.docker.com/repository/docker/bkjaya1952/docker-zoneminder-php7.4-mysql8

Usage :

To create a zoneminder-1.36 docker container (name zm)with php 7.4 ,mysql 8 & msmtp

On the Ubuntu terminal enter the following commands

sudo docker create -t -p 8080:80 --name zm --privileged=true -e TZ=Asia/Colombo bkjaya1952/docker-zoneminder-php7.4-mysql8:latest

Note:- Replace Asia/Colombo with your Time Zone

sudo docker start zm

(You will have to configure the running zm container for mysql 8 ,zm data base and make some changes to start apache and zoneminder during the first run .)

sudo docker exec -t -i zm /bin/bash

(Now you will be with in the zm container.

Make changes as follows)

(Configuring Mysql )

updatemysql.sh

exit

sudo docker restart zm

http://localhost:8080/zm/

(To use msmtp for emailing please refer https://bkjaya.wordpress.com/2020/12/24/how-to-install-the-latest-zoneminder-master-latest-on-ubuntu-20-04-using-a-docker-image/)

Note:- If you want your docker container zm to detect ip camera automatically, you will have to use the following command when creating the container .

sudo docker create -t -p 80:80 --name zm --network=host --privileged=true -e TZ=Asia/Colombo bkjaya1952/docker-zoneminder-php7.4-mysql8:latest

In this case you will have to restrain in using the port 80 in your host for any other purpose when running the zm container.

Then the zoneminder web panel will be at http://localhost/zm/

Figure:- ZM Console after adding USB Cameara

How to Install ZoneMinder-1.36.0-focal1. on UBUNTU 20.04 LTS ( Focal Fossa)

Installation of Zoneminder

To install Zoneminder v1.36.0-focal1. (stable)Please refer Connor’s web site Open the terminal and run following commands.

sudo su

sudo add-apt-repository ppa:iconnor/zoneminder-1.36

sudo apt-get update

apt install zoneminder

Configuring Mysql

/etc/init.d/mysql start

mysql -e "drop database zm;"

mysql -uroot --password=""< /usr/share/zoneminder/db/zm_create.sql 2>/dev/null

mysql -e "ALTER USER 'zmuser'@localhost IDENTIFIED BY 'zmpass';"

mysql -e "GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;"

mysql -e "FLUSH PRIVILEGES ;"

Configuring Zoneminder

chmod 740 /etc/zm/zm.conf

chown root:www-data /etc/zm/zm.conf 

adduser www-data video

a2enmod cgi 

a2enconf zoneminder

a2enmod rewrite 

a2enmod headers 

a2enmod expires 

Starting Zoneminder and apache

systemctl enable zoneminder

service zoneminder start

service apache2 reload

Open zoneminder web console (http://localhost/zm/)

Figure:- ZM Console after adding USB Cameara

How to install ivms4200-(V2.8.2.2_ML)-Linux on Ubuntu

In this tutorial ,we are going to use “Docker: Enterprise Container Platform”  (docker.io) on Ubuntu 20.04 LTS ( Focal Fossa)

First

Installation of Docker on Ubuntu 20.04 LTS ( Focal Fossa )

On the Ubuntu terminal

sudo apt install docker.io







Please refer http://www.hikvisioneurope.com/portal/?dir=portal/Technical%20Materials/11%20%20Software/01%20%20Video%20Management%20Software/00%20%20%20iVMS4200

A docker image pre-installed ivms4200-(V2.8.2.2_ML)-Linux based on bkjaya1952/q4wine-x11vnc-novnc-docker

Usage :-

To create a ivms container (name ivms) using bkjaya1952/ivms4200-(V2.8.2.2_ML)-linux Refer:- https://hub.docker.com/r/bkjaya1952/ivms4200-v2.8.2.2_ml-linux On the Ubuntu terminal

sudo docker create -t -p 8008:8080 --name ivms --privileged=true bkjaya1952/ivms4200-v2.8.2.2_ml-linux

sudo docker start ivms

xdg-open http://localhost:8008/vnc_lite.html

https://raw.githubusercontent.com/bkjaya2020/docker-ivms4200-linux-new/master/Screenshot%20from%202021-05-10%2022-04-53.png

You will get the wine desktop as follows. Please notice the ivms-4200 startup icon on the wine desktop

You will have to double click the ivms-4200 icon to get the ivms-400 desktop panel

https://raw.githubusercontent.com/bkjaya2020/docker-ivms4200-linux-new/master/Screenshot%20from%202021-05-10%2022-22-35.png
https://raw.githubusercontent.com/bkjaya2020/docker-ivms4200-linux-new/master/Screenshot%20from%202021-05-10%2022-29-50.png
https://raw.githubusercontent.com/bkjaya2020/docker-ivms4200-linux-new/master/Screenshot%20from%202020-03-01%2016-53-49.png

How to change the timezone

After quitting the noVNC

On the terminal enter

vim /etc/timezone

Then the timezone file is opened

Go to the top line of the file , press insert key on your key board and enter your timezone ( ie Asia/Colombo)

Then press the Esc key and Shift : x to save & quit the file

For more details on installation please refer the flowing video

How to control your electrical circuits at home remotely over the internet using a 6-7$ dollar wifi smart switch.

I have found an interesting wifi smart switch that can be used to power on/off electrical circuits remotely over the internet , using a smart phone .

You can use these switches in home surveillance systems.

The prices of the switches are very low as 6-7 $ dollars

The wiring of the switches is very simple .

I have found two brands of switches of low price namely ” Tuya ” and ” Sonoff “

The lowest price was Tuya . Therefore I have purchased “Tuya ” for testing purpose.

Figure:-1 Tuya wi-fi Smart switch

The Tuya wi-fi Smart switch has to be connected to the electrical circuit serially . It is very important to connect Live and Neutral wires of the circuit to the terminals of the switch as shown by L & N.

For testing purpose, I have selected a simple circuit of light bulb connected to a plug through the smart wi-fi switch as shown in the figure below.

Figure:-2 simple circuit of light bulb connected to a plug through the smart wi-fi switch

Figure:-3 Tools used to fix the wires , Tester , Slotted Head & Hexagon screw drivers

The tester was used to identify the Live and Neutral wires of the circuit. The small Hexagon screw driver was used to fix the outer cover of the switch. The small Slotted head screw driver was used to fix the wires to the switch.

Installed the Tuya app on the smart phone

Then the plug was inserted to the power socket and switched on the power and pressed the small black button about 7 seconds to activate wi-fi in the smart switch and add the switch to the Tuya app in the smart phone.

After adding the smart switch to the Tuya app , It was found the On/Off of the circuit can be controlled using the app in the smart phone

The wi-fi smart switch is connected to the mobile phone app ,over the internet,through the router with wi-fi facility .

The wifi smart switch should be in the local network of the router.

After the connection is activated , The switch can be controlled remotely over the internet from any where

Figure:-4 How the smart switch connects with the internet

Figure:- 6 How the switch is working

How to activate the Shutdown button of ZM-Console of Zoneminder master 1.35.27~20210504142217-focal on UBUNTU 20.04 LTS ( Focal Fossa)

The installation of the latest Zoneminder master 1.35.27~20210504142217-focal is same as the procedure described in the following link

Zoneminder master installation

A Shutdown button has been introduced to the latest Zoneminder master 1.35.27~20210504142217-focal issued today.

The main purpose of the Shutdown button is to allow admin users to power off or restart the system from the ZoneMinder UI

For Activating the SYSTEM_SHUTDOWN Button, you will have to edit the /etc/sudoers file as follows.

Open the Ubuntu terminal & run the following commands

sudo gedit /etc/sudoers

On the opened sudoers file add the following line and save the file

www-data ALL=NOPASSWD: /sbin/shutdown

Then the edited file is shown below

Figure:-2 Amended sudoers file at /etc/sudoers

Now restart the Zoneminder and find the Shutdown button is activated as shown below.

Figure:-3 Shutdown button is working

Once the SHUTDOWN button is activated , You can Shutdown / Restart the computer from the ZoneMinder UI. 

How to install the Zoneminder master latest on Ubuntu 18.04 ( bionic )using a docker image

Zoneminder-master , latest. docker image with Mysql 8 & MSMTP

Based on Isaac Connor’s ZoneMinder Master Snapshots at https://launchpad.net/~iconnor/+archive/ubuntu/zoneminder-master

This image has been created on ubuntu:focal with zoneminder-master/ubuntu focal main To pull the Repository from the dockerhub please refer the following link

https://hub.docker.com/r/bkjaya1952/docker-zoneminder-master-mysql5.7-php7.2

Usage :

To create a Zonminder-master docker container (name zm)with mysql 8 & msmtp

On the Ubuntu terminal enter the following commands

sudo docker create -t -p 8080:80 --name zm --privileged=true -e TZ=Asia/Colombo bkjaya1952/docker-zoneminder-master-mysql5.7-php7.2

Note:- Replace Asia/Colombo with your Time Zone

sudo docker start zm

(You will have to configure the running zm container for mysql 8 ,zm data base during the first run .)

sudo docker exec -t -i zm /bin/bash

Now you will be with in the zm container.

Make changes as follows)

(Configuring Mysql )

firstrun.sh

Note :- If ” firstrun.sh ” can’t create user then try the following command

updatemysql.sh

exit

sudo docker restart zm

http://localhost:8080/zm/

How to Install ZoneMinder-Master ,latest (revised) on UBUNTU 20.04 LTS ( Focal Fossa)

Installation of Zoneminder To install Zoneminder-Master , Please refer Connor’s web site Open the terminal and run following commands.

Note:- After releasing zoneminder master 1.35.21~20210322130228-focal , mysql 8 configuring is not essential , when installing zoneminder master

Installing Zoneminder master

sudo su 

sudo add-apt-repository ppa:iconnor/zoneminder-master 

sudo apt update 

apt install zoneminder

Configuring Zoneminder

chmod 740 /etc/zm/zm.conf 

chown root:www-data /etc/zm/zm.conf  

adduser www-data video 

a2enmod cgi  

a2enconf zoneminder 

a2enmod rewrite  

a2enmod headers  

a2enmod expires 




Starting Zoneminder and apache

systemctl enable zoneminder 

service zoneminder start  

service apache2 reload   
Open zoneminder web console (http://localhost/zm/)

Figure:- ZM-Console with a network IP Camera & USB Camera Monitors

Note:- If you want to re configure mysql 8 data base , Please refer the following link .

If the above procedure is not successful , Please drop the zm data base and re create the data base as follows

mysql -e "drop database zm;"

mysql -uroot --password=""< /usr/share/zoneminder/db/zm_create.sql 2>/dev/null

mysql -e "ALTER USER 'zmuser'@localhost IDENTIFIED BY 'zmpass';"

mysql -e "GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;"

mysql -e "FLUSH PRIVILEGES ;"