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

The  software MSMTP is a latest  SMTP client runs on a wide variety of platforms. It seems msmtp is overtaking ssmtp which is a software of similar nature.

At present the Zoneminder has been  programmed  to use ssmtp as an email software under NEW_MAIL_MODULES.

To send email alerts in , a programme has been written to use MIME::Lite module  which uses “sendmail” command.

The worked example in this blog post shows how to use MSMTP  insted of SSMPT  in Zoneminder to send email alerts of motion detection events.


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

Open the Ubuntu terminal and run

sudo apt install msmtp

After installing , you can find the main executable file msmtp at /usr/binScreenshot from 2019-10-21 11-17-51

Figure:- 1 msmtp file created at /usr/bin/

Then create   sendmail file which a symlink of  msmtp ( at /usr/bin)  in /usr/sbin/ .

Run on the Ubuntu terminal

sudo ln -s /usr/bin/msmtp /usr/sbin/sendmail

Note: before making above symlink , make sure that there is no sendmail file in /usr/bin

When searchs  for /usr/sbin/sendmail , it redirect to msmtp which is the main executable file at /usr/bin/.

Screenshot from 2019-10-20 22-51-42

Figure:-2 sendmail file at /usr/sbin

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

Creating a ~/.msmtprc file in home directory is not essential as we are making a file at /etc/ . Then msmtp   by default , connects with    msmtprc at /etc/

On the Ubuntu terminal

sudo gedit /etc/msmtprc

Screenshot from 2019-10-21 11-13-49

Figure:- 3 msmtprc at /etc/

When the empty file is opened, enter the following scripts

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

# Gmail
account gmail
port 587
from your gmail address
user your gmail address
password your gmail password

# Set a default account
account default : gmail


Screenshot from 2019-10-21 22-16-22

Figure:-4 Scrips in /etc/msmtprc

To add group www-data to the file

Then on the Ubuntu terminal

sudo chown root:www-data /etc/msmtprc

Now you can try a test mail on the terminal


echo "Subject: sendmail test" | sendmail -v


Note : replace with your receiving email

How to make changes in Zoneminder for MSMTP

It is assumed that the Zoneminder software is already installed in your Ubuntu PC

Please refer the following link for installation guide for Zoneminder


Screenshot from 2019-10-21 11-07-57

Figure:- 5 ZM-console

Go to Options/Email on the ZM-Console

And  tick boxes and make changes in the cages as sown in following two figures


Screenshot from 2019-10-21 22-43-28

Figure:- 6 Upper part of the page at Options/Email

Please note the following additional entries under EMAIL_BODY cage

Attach (first) event image with the highest score : %EIM%

Attach event mpeg video : %EV%


Screenshot from 2019-10-21 11-10-46

Figure:-7 Lower part of the page at Options/Email

Making a filter to initiate email process

Make a filter as shown in the figure below and execute

Screenshot from 2019-10-21 09-47-52

Figure:-8 filter to select events of maximum score is > or= to 5 and send email alerts

Screenshot from 2019-10-21 11-26-15

Figure:- 9 Zm-System Log showing email sending process

Following 2 figures show the received emails

Screenshot from 2019-10-21 11-11-31

Figure:- 10 received email alerts

Screenshot from 2019-10-21 12-44-34


Figure:- 11 received email alerts







NOTE:- Please refer the following link to find the latest developments :

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

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

  1. Awesome! tutorial very helpful. Wondering if you could help me with an SMS issue. Sending Email and SMS notifications working perfectly except I don’t receive %EIM% images in text message.

  2. Hello Sir,
    thank you for your blog post. I proceed as descriped but I get the following error message when I execute the filter:
    zmfilter_5[32030].ERR [main:879] [Unable to send email: error closing /usr/lib/sendmail: (exit 19968)]

    Do you have any ideas whars wrong? I checked an the path /usr/lib/sendmail is symlink to msmtp.

    Best regards,

  3. Hi Michael

    The correct link should be /usr/sbin/sendmail .

    Therefore delete the /usr/lib/sendmail and follow the instructions given in the blog post to create link /usr/sbin/sendmail

    • Hi B.K.Jayasundera,

      I removed the symlink as you wrote but I still got the error message:
      2021-11-14 19:49:52 zmfilter_5 484 ERR Unable to send email: error closing /usr/sbin/sendmail: (exit 19968)
      2021-11-14 19:49:52 zmfilter_5 484 INF Sending notification email ‘ZoneMinder: Alarm – Monitor-3-22 (5 – 2 30)’
      2021-11-14 19:49:52 zmfilter_5 484 INF Creating notification email

      I use Zoneminder in Version 1.34.26 but can not figure out, which line is rensponsible to send the mail in After checking the file, I was not able to find “/usr/sbin/sendmail”.
      I set also the path one time to /usr/sbin/sendmail and to also to /usr/bin/msmtp, same message. It seems, that the Perl-functions “send” and “sendmail” are use, but could not figure out in detail, dont know how to enable the debug log for this.

      Best regards,

      • Dear B.K.Jayasundera,

        I was able to solve it. Here is how I have done it:
        In line 897 the Method send is called:
        $mail->send(‘sendmail’, $ssmtp_location, $$filter{EmailTo});

        First I noticed, when I type in sendmail in the console, the error message
        -bash: sendmail: command not found
        You need to echo the $PATH variable to see in which path you need to put the symlink. In my case, a Debian lxc container with minimal configuration, it was
        sudo ln -s /usr/bin/msmtp /usr/bin/sendmail

        Now when you type sendmail -v in the console, the msmtp version information should appear.

        The second problem: No read permission for /etc/msmtprc.
        As I tested msmtp with
        echo “Subject: sendmail test” | sendmail -v your@mail.tld
        The first live after you push enter was:
        ignoring system configuration file /etc/msmtprc: Permission denied
        Just grant access for the users with:
        sudo chmod 744 /etc/msmtprc

        Thank you for your offer for help!

        Best regards,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s