From 35617a6cf7963cc8e37d9e9509d4d062997a0b5a Mon Sep 17 00:00:00 2001 From: dreaddy Date: Mon, 2 Nov 2015 22:16:10 -0500 Subject: [PATCH 1/4] #1128 - Added option to enable send email by ssmtp mail. Option for custom ssmtp path. Conditional checks for new options in filter --- .../lib/ZoneMinder/ConfigData.pm.in | 28 +++++++++++++++++++ scripts/zmfilter.pl.in | 20 +++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index 7fff3d62e..d5da2eb9d 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -4045,6 +4045,34 @@ body = "ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% s type => $types{string}, category => "eyeZm", }, + { + name => "ZM_SSMTP_MAIL", + default => "no", + description => "Use a SSMTP mail server if available. NEW_MAIL_MODULES must be enabled", + requires => [ + { name => "ZM_OPT_EMAIL", value => "yes" }, + { name => "ZM_OPT_MESSAGE", value => "yes" }, + { name => "ZM_NEW_MAIL_MODULES", value => "yes" } + ], + help => qqq(" + Please visit the following wiki page for more information on setting up ssmtp: http://www.zoneminder.com/wiki/index.php/How_to_get_ssmtp_working_with_Zoneminder. + "), + type => $types{boolean}, + category => "mail", + }, + { + name => "ZM_SSMTP_PATH", + default => "", + description => "SSMTP path custom location", + requires => [ + { name => "ZM_SSMTP_MAIL", value => "yes" } + ], + help => qqq(" + Please visit the following wiki page for more information on setting up ssmtp: http://www.zoneminder.com/wiki/index.php/How_to_get_ssmtp_working_with_Zoneminder. + "), + type => $types{string}, + category => "mail", + }, ); our %options_hash = map { ( $_->{name}, $_ ) } @options; diff --git a/scripts/zmfilter.pl.in b/scripts/zmfilter.pl.in index 54f372262..d038488b4 100755 --- a/scripts/zmfilter.pl.in +++ b/scripts/zmfilter.pl.in @@ -1165,9 +1165,25 @@ sub sendEmail Disposition => "attachment" ); } + if ( $Config{ZM_SSMTP_MAIL} ){ + + my $ssmtp_location = qx('which ssmtp'); + + if( $Config{ZM_SSMTP_PATH} ){ + + $ssmtp_location = $Config{ZM_SSMTP_PATH} + } + + $mail->send( 'sendmail', $ssmtp_location, $Config{ZM_EMAIL_ADDRESS} ); + + }else{ + + MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 ); + $mail->send(); + } ### Send the Message - MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 ); - $mail->send(); + #MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 ); + #$mail->send(); } else { From ced0240fc3817a5dd724875d5327501db877a77e Mon Sep 17 00:00:00 2001 From: dreaddy Date: Fri, 6 Nov 2015 10:43:30 -0500 Subject: [PATCH 2/4] Use the ssmtp path set in options first. shell command if ssmtp path empty. display debug suggesting set ssmtp path in option. --- scripts/zmfilter.pl.in | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/zmfilter.pl.in b/scripts/zmfilter.pl.in index d038488b4..7e335a30f 100755 --- a/scripts/zmfilter.pl.in +++ b/scripts/zmfilter.pl.in @@ -1167,11 +1167,17 @@ sub sendEmail } if ( $Config{ZM_SSMTP_MAIL} ){ - my $ssmtp_location = qx('which ssmtp'); + my $ssmtp_location = $Config{ZM_SSMTP_PATH} - if( $Config{ZM_SSMTP_PATH} ){ + if( ! $ssmtp_location ){ + + $ssmtp_location = qx('which ssmtp'); + + if ( logDebugging() ) + { + Debug( "which ssmtp: $ssmtp_location - set ssmtp path in options to suppress this message\n" ); + } - $ssmtp_location = $Config{ZM_SSMTP_PATH} } $mail->send( 'sendmail', $ssmtp_location, $Config{ZM_EMAIL_ADDRESS} ); From 92401193a76d7b45d8a4aeacb4236ddf9f47d547 Mon Sep 17 00:00:00 2001 From: dreaddy Date: Fri, 6 Nov 2015 11:19:12 -0500 Subject: [PATCH 3/4] Add missing semicolon --- scripts/zmfilter.pl.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/zmfilter.pl.in b/scripts/zmfilter.pl.in index 7e335a30f..042539907 100755 --- a/scripts/zmfilter.pl.in +++ b/scripts/zmfilter.pl.in @@ -1167,7 +1167,7 @@ sub sendEmail } if ( $Config{ZM_SSMTP_MAIL} ){ - my $ssmtp_location = $Config{ZM_SSMTP_PATH} + my $ssmtp_location = $Config{ZM_SSMTP_PATH}; if( ! $ssmtp_location ){ From 3479af78bd84c7ead3dc18b29fae12c65abf3ca2 Mon Sep 17 00:00:00 2001 From: dreaddy Date: Fri, 6 Nov 2015 13:36:29 -0500 Subject: [PATCH 4/4] Add more verbose help --- scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index d5da2eb9d..49fa87f8b 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -4055,7 +4055,9 @@ body = "ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% s { name => "ZM_NEW_MAIL_MODULES", value => "yes" } ], help => qqq(" - Please visit the following wiki page for more information on setting up ssmtp: http://www.zoneminder.com/wiki/index.php/How_to_get_ssmtp_working_with_Zoneminder. + +SSMTP is a lightweight and efficient method to send email. The SSMTP application is not installed by default. NEW_MAIL_MODULES must also be enabled Please visit: http://www.zoneminder.com/wiki/index.php/How_to_get_ssmtp_working_with_Zoneminder setup and configuration help. + "), type => $types{boolean}, category => "mail", @@ -4063,12 +4065,12 @@ body = "ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% s { name => "ZM_SSMTP_PATH", default => "", - description => "SSMTP path custom location", + description => "SSMTP executable path", requires => [ { name => "ZM_SSMTP_MAIL", value => "yes" } ], help => qqq(" - Please visit the following wiki page for more information on setting up ssmtp: http://www.zoneminder.com/wiki/index.php/How_to_get_ssmtp_working_with_Zoneminder. +Recommend setting the path to the SSMTP application. If path is not defined. Zoneminder will try to determined the path via shell command. Example path: /usr/sbin/ssmtp. "), type => $types{string}, category => "mail",