Merge branch 'dreaddy-1128_ssmtp_mail_option'

This commit is contained in:
Andrew Bauer 2016-04-21 07:27:39 -05:00
commit 41a68bdc6d
2 changed files with 59 additions and 2 deletions

View File

@ -3825,6 +3825,41 @@ body = "ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% s
readonly => 1, readonly => 1,
category => "dynamic", category => "dynamic",
}, },
{
name => "ZM_SSMTP_MAIL",
default => "no",
description => qqq("
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("
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
for setup and configuration help.
"),
type => $types{boolean},
category => "mail",
},
{
name => "ZM_SSMTP_PATH",
default => "",
description => "SSMTP executable path",
requires => [{ name => "ZM_SSMTP_MAIL", value => "yes" }],
help => qqq("
Recommend setting the path to the SSMTP application.
If path is not defined. Zoneminder will try to determine
the path via shell command. Example path: /usr/sbin/ssmtp.
"),
type => $types{string},
category => "mail",
},
); );
our %options_hash = map { ( $_->{name}, $_ ) } @options; our %options_hash = map { ( $_->{name}, $_ ) } @options;

View File

@ -1179,10 +1179,32 @@ sub sendEmail
Disposition => "attachment" Disposition => "attachment"
); );
} }
### Send the Message if ( $Config{ZM_SSMTP_MAIL} ){
my $ssmtp_location = $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" );
}
}
$mail->send( 'sendmail', $ssmtp_location, $Config{ZM_EMAIL_ADDRESS} );
}else{
MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 ); MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 );
$mail->send(); $mail->send();
} }
### Send the Message
#MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 );
#$mail->send();
}
else else
{ {
my $mail = MIME::Entity->build( my $mail = MIME::Entity->build(