Zoneminder ignoring SSMTP_PATH setting

Forum for questions and support relating to the 1.30.x releases only.
Locked
MystX
Posts: 4
Joined: Mon Oct 10, 2016 6:59 am

Zoneminder ignoring SSMTP_PATH setting

Post by MystX »

Hi guys,

I am running Zoneminder 1.30 from the PPA on Ubuntu 16.04.
I have had ssmtp set up and it works fine. BUT I am trying to redirect the call to another executable.

I have set SSMTP_PATH to point to another executable that is in a directory executable and writable by anyone.
Changing the SSMTP_PATH setting in email settings does not change the behaviour, and emails are still sent directly through ssmtp.

Am I missing something or is Zoneminder ignoring this setting?
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Zoneminder ignoring SSMTP_PATH setting

Post by knight-of-ni »

We can't answer your question without seeing your configuration. Screenshot is preferred.

Did you follow the ssmtp instructions in the wiki?

You haven't told us what the other executable is or why you want to do this, but if that executable does not take exactly the same parameters as ssmpt, I doubt it will work the way you want it to.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
MystX
Posts: 4
Joined: Mon Oct 10, 2016 6:59 am

Re: Zoneminder ignoring SSMTP_PATH setting

Post by MystX »

Thanks for the reply.

Email config can be found here: https://puu.sh/rEnYm/8630d12368.png
knnniggett wrote:Did you follow the ssmtp instructions in the wiki?
Yeah as I say, ssmtp was set up and has been working for the last few months. Now I want Zoneminder to run a script instead of ssmtp - so that I can stop emails being sent on some criteria.
knnniggett wrote:You haven't told us what the other executable is or why you want to do this, but if that executable does not take exactly the same parameters as ssmpt, I doubt it will work the way you want it to.
It's a bash script so it will actually run with any parameters. All it will be doing is some extra logic (like checking if I'm home).
But I've now replaced it with a completely empty script - so it does literally nothing. My issue is that I'm still getting emails :? so I think Zoneminder is ignoring the path setting in the screenshot above.
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Zoneminder ignoring SSMTP_PATH setting

Post by knight-of-ni »

The script you are pointing to does not send mail, and therein lies the problem. ZoneMinder uses Perl's MIME::Lite->send method to send mail. ZoneMinder simply tells the module where the default location for the ssmtp executable is. I do not expect any other executable or script, other than another mail utility, will work.

What I also suspect is that the MIME::Lite method is indeed calling your script, but when it does not get the results it expects, it finds the real mail utility on its own from your path. You could test this easy enough by getting the script to do something like "touch /home/scripts/zm_called_me.txt"

You can see the code starting here:
https://github.com/ZoneMinder/ZoneMinde ... pl.in#L799
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
MystX
Posts: 4
Joined: Mon Oct 10, 2016 6:59 am

Re: Zoneminder ignoring SSMTP_PATH setting

Post by MystX »

Based on the code you provided, Zoneminder uses this line to send:

Code: Select all

$mail->send( 'sendmail', $ssmtp_location, $Config{ZM_EMAIL_ADDRESS} );
In the MIME::Lite docs, they suggest that the path can point to anything, and even suggest writing your own script to send mail, and point the given path to that script. The default value for the ssmtp path given by Zoneminder is actually /usr/lib/sendmail, which is not set up on my system. The same docs also say "Returns true on success, false or exception on error." for this, so I don't think the MIME::Lite library is checking whether the called program actually sends mail or not (and I don't see how it could).

I have tested your suggestion by having my script create a file, and the file is never created - which leads me to think my script is never called.

EDIT: It's worth mentioning too that ssmtp is definitely being run, and not some other MIME::Lite method of sending mail. Ssmtp writes to the syslog when it is run by Zoneminder every time there is an event.
MystX
Posts: 4
Joined: Mon Oct 10, 2016 6:59 am

Re: Zoneminder ignoring SSMTP_PATH setting

Post by MystX »

I have done some more digging.

- The default path for MIME::Lite to use as I mentioned is

Code: Select all

/usr/lib/sendmail
- On my system this is symlinked to the ssmtp binary. Ssmtp is not being called directly, but sendmail is being run, regardless of the ZM_SSMTP_PATH setting.
- Replacing the sendmail link with a link to my script causes it to run, and everything works as expected.

So for whatever reason, the path is being ignored. It doesn't seem like it's Zoneminder doing it, but the library.
Locked