ZM Email

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
weswitt
Posts: 5
Joined: Wed Jul 22, 2020 8:33 pm

ZM Email

Post by weswitt » Wed Jul 22, 2020 9:33 pm

I'm having problems getting ZM to send email successfully.

I have MSMTP properly configured and I can send email via the command line using MAIL, MSMTP and SENDMAIL.

When I attempt to send an email for an event from the filter page I get this error in the log: "Unable to send email: error closing /usr/lib/sendmail: (exit 19968)".

Jul 22 14:28:44 zoneminder zmfilter_4[1070]: INF [Creating notification email]
Jul 22 14:28:44 zoneminder zmfilter_4[1070]: INF [Sending notification email 'ZoneMinder: Alarm - Monitor-1-1 (26 - 16 18)']
Jul 22 14:28:44 zoneminder zmfilter_4[1070]: ERR [Unable to send email: error closing /usr/lib/sendmail: (exit 19968)]

Any ideas what is causing this?

Email options:
OPT_EMAIL: enabled
OPT_MESSAGE: enabled
NEW_MAIL_MODULES: enabled
SSMTP_MAIL: enabled
SSMTP_PATH: /usr/bin/msmtp
EMAIL_ADDRESS, MESSAGE_ADDRESS, FROM_EMAIL: all set to my email address

weswitt
Posts: 5
Joined: Wed Jul 22, 2020 8:33 pm

Re: ZM Email

Post by weswitt » Thu Jul 23, 2020 12:10 am

it seems that for some reason zm is using /usr/lib/sendmail instead of the configured email client. there are no entries in the msmtp log.

furthermore i write a simple perl script that simulates what zm does in zmfilter.pl and it works perfectly:

#!/usr/bin/perl
use MIME::Lite;
use Net::SMTP;
my $from_address = 'foo@bar.com';
my $to_address = 'foo@bar.com';
my $subject = 'test msg';
my $message_body = "*** body ****";
$msg = MIME::Lite->new(
From => $from_address,
To => $to_address,
Subject => $subject,
Type =>'multipart/mixed'
);
$msg->attach(Type => 'TEXT', Data => $message_body);
$msg->send('sendmail', '/usr/bin/msmtp', $from_address);

burger
Posts: 124
Joined: Mon May 11, 2020 4:32 pm

Re: ZM Email

Post by burger » Thu Jul 23, 2020 4:25 pm

In my older ZM, sendmail is an alias to ssmtp. Is yours an alias to msmtp?

Code: Select all

:/usr/lib$ ls -l sendmail
lrwxrwxrwx 1 root root 16 Jul 14  2014 sendmail -> ../sbin/sendmail
:/usr/sbin$ ls -l sendmail
lrwxrwxrwx 1 root root 5 Jul 14  2014 sendmail -> ssmtp
Note that ssmtp doesn't work in buster, with all email providers due to encryption issues, so I'll be using msmtp, when I upgrade.
fastest way to test streams:
ffmpeg -i rtsp://<ipaddress>:554/path output.mp4
from terminal, and run through paths on ispydb or in zm hcl

If you are new to cctv, read this:
https://wiki.zoneminder.com/Dummies_Guide

weswitt
Posts: 5
Joined: Wed Jul 22, 2020 8:33 pm

Re: ZM Email

Post by weswitt » Thu Jul 23, 2020 4:34 pm

for me sendmail is a soft link to msmtp. fyi, i'm running ubuntu server 20.04 on an intel core i7 pc.

burger
Posts: 124
Joined: Mon May 11, 2020 4:32 pm

Re: ZM Email

Post by burger » Thu Jul 23, 2020 4:45 pm

So it is using msmtp then? You can add debugging printfs to the zm_filter.pl fairly easily (if necessary...). But first enable debugging in msmtp. Not sure how that's handled but in ssmtp you could enable debugging (Debug=YES), and then logs in /var/log/mail.log would have verbose details.

There are email troubleshooting guides here:
https://wiki.zoneminder.com/How_to_get_ ... Zoneminder
and
https://wiki.zoneminder.com/SMS_Notifications
fastest way to test streams:
ffmpeg -i rtsp://<ipaddress>:554/path output.mp4
from terminal, and run through paths on ispydb or in zm hcl

If you are new to cctv, read this:
https://wiki.zoneminder.com/Dummies_Guide

weswitt
Posts: 5
Joined: Wed Jul 22, 2020 8:33 pm

Re: ZM Email

Post by weswitt » Thu Jul 23, 2020 5:11 pm

i have tried changing the sendmail link to ssmtp and the same failure occurs.

i have added several logging calls in zm_filter to track the flow. i can see from the added log calls that control flow ends up at line 852:

$mail->send('sendmail', $ssmtp_location, $Config{ZM_EMAIL_ADDRESS});

the failure happens with this call. the $ssmtp_location and ZM_EMAIL_ADDRESS values are both correct. these is something else happening.

weswitt
Posts: 5
Joined: Wed Jul 22, 2020 8:33 pm

Re: ZM Email

Post by weswitt » Thu Jul 23, 2020 5:39 pm

i actually go this working.

i realized that there were 2 instances of sendmail on my system: /usr/sbin/sendmail and /usr/lib/sendmail, zm seems to use /usr/lib/sendmail. i changed the soft links at both locations to ssmtp and now email works. i have no idea why it failed when the links pointed to msmtp because both ssmtp and msmtp are 100% compatible with sendmail so both should work. i guess i really don't care as long as email works.

User avatar
bkjaya1952
Posts: 97
Joined: Sat Aug 25, 2018 3:24 pm
Location: Sri Lanka
Contact:

Re: ZM Email

Post by bkjaya1952 » Thu Jul 23, 2020 6:10 pm

Please see the link to get the details on How to use MSMTP as email software in Zoneminder
https://bkjaya.wordpress.com/2019/10/21 ... ntu-19-04/

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests