First you will have to install MSMTP  ( If
ssmtp , sendmail  available , please uninstall completely )

Open the terminal and run

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

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/
sudo nano /etc/msmtprc
When the empty file is opened, enter the following scripts
# 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

sudo chown root:www-data /etc/msmtprc

Now you can try a test mail on the terminal

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%