Page 1 of 1
ZM Email
Posted: Wed Jul 22, 2020 9:33 pm
by weswitt
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
Re: ZM Email
Posted: Thu Jul 23, 2020 12:10 am
by weswitt
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);
Re: ZM Email
Posted: Thu Jul 23, 2020 4:25 pm
by burger
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.
Re: ZM Email
Posted: Thu Jul 23, 2020 4:34 pm
by weswitt
for me sendmail is a soft link to msmtp. fyi, i'm running ubuntu server 20.04 on an intel core i7 pc.
Re: ZM Email
Posted: Thu Jul 23, 2020 4:45 pm
by burger
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
Re: ZM Email
Posted: Thu Jul 23, 2020 5:11 pm
by weswitt
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.
Re: ZM Email
Posted: Thu Jul 23, 2020 5:39 pm
by weswitt
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.
Re: ZM Email
Posted: Thu Jul 23, 2020 6:10 pm
by bkjaya1952
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/