Merge branch 'ent-4047-Simplificacion-de-la-configuracion-del-sistema-de-email' into 'develop'

Ent 4047 simplificacion de la configuracion del sistema de email

See merge request artica/pandorafms!2712
This commit is contained in:
Daniel Rodriguez 2019-09-20 11:57:58 +02:00
commit 409ac061e0
11 changed files with 298 additions and 97 deletions

View File

@ -58,6 +58,16 @@ global $config;
check_login();
if (is_ajax()) {
enterprise_include_once('include/functions_cron.php');
$test_address = get_parameter('test_address', '');
$res = enterprise_hook('send_email_attachment', [$test_address, __('This is an email test sent from Pandora FMS. If you can read this, your configuration works.'), __('Testing Pandora FMS email'), null]);
echo $res;
}
$table = new StdClass();
$table->class = 'databox filters';
$table->id = 'setup_general';
@ -68,6 +78,12 @@ $table->size[0] = '30%';
$table->style[0] = 'font-weight:bold';
$table->size[1] = '70%';
$table_mail_conf = new stdClass();
$table_mail_conf->width = '100%';
$table_mail_conf->class = 'databox filters';
$table_mail_conf->data = [];
$table_mail_conf->style[0] = 'font-weight: bold';
// Current config["language"] could be set by user, not taken from global setup !
$current_system_lang = db_get_sql(
'SELECT `value` FROM tconfig WHERE `token` = "language"'
@ -330,6 +346,49 @@ echo '<legend>'.__('General options').'</legend>';
html_print_input_hidden('update_config', 1);
html_print_table($table);
$encryption = [
'ssl' => 'SSL/TLS',
'sslv2' => 'SSLv2',
'sslv3' => 'SSLv3',
'tls' => 'STARTTLS',
];
echo '</fieldset>';
echo '<fieldset>';
echo '<legend>'.__('Mail configuration').'</legend>';
$table_mail_conf->data[0][0] = __('From address');
$table_mail_conf->data[0][1] = html_print_input_text('email_from_dir', $config['email_from_dir'], '', 30, 100, true);
$table_mail_conf->data[1][0] = __('From name');
$table_mail_conf->data[1][2] = html_print_input_text('email_from_name', $config['email_from_name'], '', 30, 100, true);
$table_mail_conf->data[2][0] = __('SMTP Server');
$table_mail_conf->data[2][1] = html_print_input_text('email_smtpServer', $config['email_smtpServer'], '', 30, 100, true);
$table_mail_conf->data[3][0] = __('SMTP Port');
$table_mail_conf->data[3][1] = html_print_input_text('email_smtpPort', $config['email_smtpPort'], '', 30, 100, true);
$table_mail_conf->data[4][0] = __('Encryption');
$table_mail_conf->data[4][1] = html_print_select($encryption, 'email_encryption', $config['email_encryption'], '', __('none'), 0, true);
$table_mail_conf->data[5][0] = __('Email user');
$table_mail_conf->data[5][1] = html_print_input_text('email_username', $config['email_username'], '', 30, 100, true);
$table_mail_conf->data[6][0] = __('Email password');
$table_mail_conf->data[6][1] = html_print_input_password('email_password', io_output_password($config['email_password']), '', 30, 100, true);
$uniqid = uniqid();
$table_mail_conf->data[7][0] = html_print_button(__('Email test'), 'email_test_dialog', false, "show_email_test('$uniqid');", 'class="sub next"', true).ui_print_help_tip(__('Check the current saved email configuration by sending a test email to a desired account.'), true);
print_email_test_modal_window($uniqid);
html_print_input_hidden('update_config', 1);
html_print_table($table_mail_conf);
echo '</fieldset>';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
@ -337,6 +396,25 @@ html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"'
echo '</div>';
echo '</form>';
// Print the modal window for the summary of each alerts group
function print_email_test_modal_window($id)
{
// Email config table.
$table_mail_test = new stdClass();
$table_mail_test->width = '100%';
$table_mail_test->class = 'databox filters';
$table_mail_test->data = [];
$table_mail_test->style[0] = 'font-weight: bold';
$table_mail_test->colspan[1][0] = 2;
$table_mail_test->data[0][0] = __('Address').ui_print_help_tip(__('Email address to which the test email will be sent. Please check your inbox after email is sent.'), true);
$table_mail_test->data[0][1] = html_print_input_text('email_test_address', '', '', 40, 100, true);
$table_mail_test->data[1][0] = html_print_button(__('Send'), 'email_test', false, '', 'class="sub next"', true).'&nbsp&nbsp<span id="email_test_sent_message" style="display:none;">Email sent</span><span id="email_test_failure_message" style="display:none;">Email could not been sent</span>';
echo '<div id="email_test_'.$id.'" title="'.__('Check mail configuration').'" style="display:none">'.html_print_table($table_mail_test, true).'</div>';
}
?>
<script type="text/javascript">
@ -375,6 +453,40 @@ function show_timezone () {
});
}
function show_email_test(id) {
$('#email_test_sent_message').hide();
$('#email_test_failure_message').hide();
$("#email_test_"+id).dialog({
resizable: true,
draggable: true,
modal: true,
height: 175,
width: 450,
overlay: {
opacity: 0.5,
background: "black"
}
});
}
function perform_email_test () {
var test_address = $('#text-email_test_address').val();
$.ajax({
type: "POST",
url: "ajax.php",
data: "page=godmode/setup/setup_general&test_address="+test_address,
dataType: "html",
success: function(data) {
$('#email_test_sent_message').show();
},
error: function() {
$('#email_test_failure_message').show();
},
});
}
$(document).ready (function () {
$("#zone").attr("hidden", true);
@ -431,5 +543,7 @@ $(document).ready (function () {
});
}
})
$('input#button-email_test').click(perform_email_test);
});
</script>

View File

@ -325,6 +325,34 @@ function config_update_config()
if (!config_update_value('unique_ip', get_parameter('unique_ip'))) {
$error_update[] = __('unique_ip');
}
if (!config_update_value('email_smtpServer', get_parameter('email_smtpServer'))) {
$error_update[] = __('Server SMTP');
}
if (!config_update_value('email_from_dir', get_parameter('email_from_dir'))) {
$error_update[] = __('From dir');
}
if (!config_update_value('email_from_name', get_parameter('email_from_name'))) {
$error_update[] = __('From name');
}
if (!config_update_value('email_smtpPort', (int) get_parameter('email_smtpPort'))) {
$error_update[] = __('Port SMTP');
}
if (!config_update_value('email_encryption', get_parameter('email_encryption'))) {
$error_update[] = __('Encryption');
}
if (!config_update_value('email_username', get_parameter('email_username'))) {
$error_update[] = __('Email user');
}
if (!config_update_value('email_password', get_parameter('email_password'))) {
$error_update[] = __('Email password');
}
break;
case 'enterprise':
@ -419,34 +447,6 @@ function config_update_config()
if (!config_update_value('inventory_changes_blacklist', implode(',', $inventory_changes_blacklist))) {
$error_update[] = __('Inventory changes blacklist');
}
if (!config_update_value('email_from_dir', get_parameter('email_from_dir'))) {
$error_update[] = __('From dir');
}
if (!config_update_value('email_from_name', get_parameter('email_from_name'))) {
$error_update[] = __('From name');
}
if (!config_update_value('email_smtpServer', get_parameter('email_smtpServer'))) {
$error_update[] = __('Server SMTP');
}
if (!config_update_value('email_smtpPort', (int) get_parameter('email_smtpPort'))) {
$error_update[] = __('Port SMTP');
}
if (!config_update_value('email_encryption', get_parameter('email_encryption'))) {
$error_update[] = __('Encryption');
}
if (!config_update_value('email_username', get_parameter('email_username'))) {
$error_update[] = __('Email user');
}
if (!config_update_value('email_password', get_parameter('email_password'))) {
$error_update[] = __('Email password');
}
}
break;

View File

@ -6,5 +6,5 @@ Section: admin
Installed-Size: 640
Maintainer: ÁRTICA ST <info@artica.es>
Homepage: http://pandorafms.org/
Depends: perl (>= 5.8), libdbi-perl, libdbd-mysql-perl, libtime-format-perl, libnetaddr-ip-perl, libtime-format-perl, libxml-simple-perl, libxml-twig-perl, libhtml-parser-perl, snmp, snmpd, traceroute, xprobe2, nmap, sudo, libwww-perl, libsocket6-perl, libio-socket-inet6-perl, snmp-mibs-downloader, libjson-perl, libnet-telnet-perl, libencode-locale-perl, libgeo-ip-perl
Depends: perl (>= 5.8), libdbi-perl, libdbd-mysql-perl, libtime-format-perl, libnetaddr-ip-perl, libtime-format-perl, libxml-simple-perl, libxml-twig-perl, libhtml-parser-perl, snmp, snmpd, traceroute, xprobe2, nmap, sudo, libwww-perl, libsocket6-perl, libio-socket-inet6-perl, libio-socket-ssl-perl, snmp-mibs-downloader, libjson-perl, libnet-telnet-perl, libencode-locale-perl, libgeo-ip-perl
Description: Pandora FMS is a monitoring system for big IT environments. It uses remote tests, or local agents to grab information. Pandora supports all standard OS (Linux, AIX, HP-UX, Solaris and Windows XP,2000/2003), and support multiple setups in HA enviroments. This is the server package. Server makes the remote checks and process information transfer by Pandora FMS agents to the server.

View File

@ -365,9 +365,11 @@ sub pandora_server_tasks ($) {
# COMMON TASKS (master and non-master)
# ---------------------------------------------------------------
# Rotate Log File
if (($counter % 30) == 0) {
# Update configuration options from the console.
pandora_get_sharedconfig ($pa_config, $dbh);
# Rotate the log file.
pandora_rotate_logfile($pa_config);
# Set event storm protection

View File

@ -226,8 +226,9 @@ recon_threads 1
dataserver_threads 1
# mta_address: External Mailer (MTA) IP Address to be used by Pandora FMS internal email capabilities
# If not set, the MTA configuration specified in the Pandora FMS Console will be used.
mta_address localhost
#mta_address localhost
# mta_port, this is the mail server port (default 25)
@ -250,6 +251,10 @@ mta_address localhost
#mta_from Pandora FMS <pandora@mydomain.com>
# SMTP encryption protocol (none, ssl, starttls)
#mta_encryption none
# Set 1 if want eMail deliver alert in separate mail (default).
# Set 0 if want eMail deliver shared mail by all destination.
mail_in_separate 1

View File

@ -214,6 +214,7 @@ recon_threads 2
dataserver_threads 2
# mta_address: External Mailer (MTA) IP Address to be used by Pandora FMS internal email capabilities
# If not set, the MTA configuration specified in the Pandora FMS Console will be used.
#mta_address localhost
@ -235,6 +236,10 @@ dataserver_threads 2
# probably you need to change it to avoid problems with your antispam
#mta_from pandora@sampledomain.com
# SMTP encryption protocol (none, ssl, starttls)
#mta_encryption none
# xprobe2: Optional package to detect OS types using advanced TCP/IP
# fingerprinting tecniques, much more accurates than stadard nmap.
# If not provided, nmap is used insted xprobe2

View File

@ -187,6 +187,33 @@ sub pandora_get_sharedconfig ($$) {
[$dbh]
);
$pa_config->{'rb_product_name'} = 'Pandora FMS' unless (defined ($pa_config->{'rb_product_name'}) && $pa_config->{'rb_product_name'} ne '');
# Mail transport agent configuration. Local configuration takes precedence.
if ($pa_config->{"mta_local"} eq 0) {
$pa_config->{"mta_address"} = pandora_get_tconfig_token ($dbh, 'email_smtpServer', '');
$pa_config->{"mta_from"} = '"' . pandora_get_tconfig_token ($dbh, 'email_from_name', 'Pandora FMS') . '" <' .
pandora_get_tconfig_token ($dbh, 'email_from_dir', 'pandora@pandorafms.org') . '>';
$pa_config->{"mta_pass"} = pandora_get_tconfig_token ($dbh, 'email_password', '');
$pa_config->{"mta_port"} = pandora_get_tconfig_token ($dbh, 'email_smtpPort', '');
$pa_config->{"mta_user"} = pandora_get_tconfig_token ($dbh, 'email_username', '');
$pa_config->{"mta_encryption"} = pandora_get_tconfig_token ($dbh, 'email_encryption', '');
# Auto-negotiate the auth mechanism, since it cannot be set from the console.
# Do not include PLAIN, it generates the following error:
# 451 4.5.0 SMTP protocol violation, see RFC 2821
$pa_config->{"mta_auth"} = 'DIGEST-MD5 CRAM-MD5 LOGIN';
# Fix the format of mta_encryption.
if ($pa_config->{"mta_encryption"} eq 'tls') {
$pa_config->{"mta_encryption"} = 'starttls';
}
elsif ($pa_config->{"mta_encryption"} =~ m/^ssl/) {
$pa_config->{"mta_encryption"} = 'ssl';
}
else {
$pa_config->{"mta_encryption"} = 'none';
}
}
}
##########################################################################
@ -303,12 +330,14 @@ sub pandora_load_config {
$pa_config->{"dynamic_constant"} = 10; # 7.0
# Internal MTA for alerts, each server need its own config.
$pa_config->{"mta_address"} = '127.0.0.1'; # Introduced on 2.0
$pa_config->{"mta_port"} = '25'; # Introduced on 2.0
$pa_config->{"mta_address"} = ''; # Introduced on 2.0
$pa_config->{"mta_port"} = ''; # Introduced on 2.0
$pa_config->{"mta_user"} = ''; # Introduced on 2.0
$pa_config->{"mta_pass"} = ''; # Introduced on 2.0
$pa_config->{"mta_auth"} = 'none'; # Introduced on 2.0 (Support LOGIN PLAIN CRAM-MD5 DIGEST-MD)
$pa_config->{"mta_from"} = 'pandora@localhost'; # Introduced on 2.0
$pa_config->{"mta_encryption"} = 'none'; # 7.0 739
$pa_config->{"mta_local"} = 0; # 7.0 739
$pa_config->{"mail_in_separate"} = 1; # 1: eMail deliver alert mail in separate mails.
# 0: eMail deliver 1 mail with all destination.
@ -582,6 +611,7 @@ sub pandora_load_config {
}
elsif ($parametro =~ m/^mta_address\s(.*)/i) {
$pa_config->{'mta_address'}= clean_blank($1);
$pa_config->{'mta_local'}=1;
}
elsif ($parametro =~ m/^mta_port\s(.*)/i) {
$pa_config->{'mta_port'}= clean_blank($1);
@ -592,6 +622,9 @@ sub pandora_load_config {
elsif ($parametro =~ m/^mta_from\s(.*)/i) {
$pa_config->{'mta_from'}= clean_blank($1);
}
elsif ($parametro =~ m/^mta_encryption\s(.*)/i) {
$pa_config->{'mta_encryption'}= clean_blank($1);
}
elsif ($parametro =~ m/^mail_in_separate\s+([0-9]*)/i) {
$pa_config->{'mail_in_separate'}= clean_blank($1);
}

View File

@ -32,7 +32,9 @@ $VERSION = '0.79_16';
'tz' => '', # only to override automatic detection
'port' => 25, # change it if you always use a non-standard port
'debug' => 0 # prints stuff to STDERR
'debug' => 0, # prints stuff to STDERR
'encryption' => 'none', # no, ssl or starttls
'timeout' => 5, # timeout for socket reads/writes in seconds
);
# *******************************************************************
@ -54,7 +56,8 @@ use vars qw(
$auth_support
);
use Socket;
use IO::Socket::INET;
use IO::Select;
use Time::Local; # for automatic time zone detection
use Sys::Hostname; # for use of hostname in HELO
@ -62,6 +65,12 @@ use Sys::Hostname; # for use of hostname in HELO
$auth_support = 'DIGEST-MD5 CRAM-MD5 PLAIN LOGIN';
# IO::Socket object.
my $S;
# IO::Select object.
my $Sel;
# use MIME::QuotedPrint if available and configured in %mailcfg
eval("use MIME::QuotedPrint");
$mailcfg{'mime'} &&= (!$@);
@ -178,9 +187,9 @@ sub sendmail {
local $_;
my (%mail, $k,
$smtp, $server, $port, $connected, $localhost,
$smtp, $server, $port, $localhost,
$fromaddr, $recip, @recipients, $to, $header,
%esmtp, @wanted_methods,
%esmtp, @wanted_methods, $encryption
);
use vars qw($server_reply);
# -------- a few internal subs ----------
@ -191,7 +200,7 @@ sub sendmail {
$error .= "Server said: $server_reply\n";
print STDERR "Server said: $server_reply\n" if $^W;
}
close S;
close $S if defined($S);
return 0;
}
@ -200,31 +209,40 @@ sub sendmail {
for $i (0..$#_) {
# accept references, so we don't copy potentially big data
my $data = ref($_[$i]) ? $_[$i] : \$_[$i];
if ($mailcfg{'debug'} > 5) {
if ($mailcfg{'debug'} > 9) {
if (length($$data) < 500) {
print ">", $$data;
print STDERR ">", $$data;
}
else {
print "> [...", length($$data), " bytes sent ...]\n";
print STDERR "> [...", length($$data), " bytes sent ...]\n";
}
}
print(S $$data) || return 0;
my @sockets = $Sel->can_write($mailcfg{'timeout'});
return 0 if (!@sockets);
syswrite($sockets[0], $$data) || return 0;
}
1;
}
sub socket_read {
my $buffer;
$server_reply = "";
do {
$_ = <S>;
$server_reply .= $_;
#chomp $_;
print "<$_" if $mailcfg{'debug'} > 5;
if (/^[45]/ or !$_) {
chomp $server_reply;
return; # return false
}
} while (/^[\d]+-/);
while (my @sockets = $Sel->can_read($mailcfg{'timeout'})) {
return if (!@sockets);
# 16kByte is the maximum size of an SSL frame and because sysread
# returns data from only a single SSL frame you can guarantee that
# there are no pending data.
sysread($sockets[0], $buffer, 65535) || return;
$server_reply .= $buffer;
last if ($buffer =~ m/\n$/);
}
print STDERR "<$server_reply" if $mailcfg{'debug'} > 9;
if ($server_reply =~ /^[45]/) {
chomp $server_reply;
return; # return false
}
chomp $server_reply;
return $server_reply;
}
@ -260,13 +278,15 @@ sub sendmail {
}
$smtp = $mail{'Smtp'} || $mail{'Server'};
unshift @{$mailcfg{'smtp'}}, $smtp if ($smtp and $mailcfg{'smtp'}->[0] ne $smtp);
$mailcfg{'smtp'}->[0] = $smtp if ($smtp and $mailcfg{'smtp'}->[0] ne $smtp);
$encryption = $mail{'Encryption'} || $mail{'Encryption'};
# delete non-header keys, so we don't send them later as mail headers
# I like this syntax, but it doesn't seem to work with AS port 5.003_07:
# delete @mail{'Smtp', 'Server'};
# so instead:
delete $mail{'Smtp'}; delete $mail{'Server'};
delete $mail{'Smtp'}; delete $mail{'Server'}; delete $mail{'Encryption'};
$mailcfg{'port'} = $mail{'Port'} || $mailcfg{'port'} || 25;
delete $mail{'Port'};
@ -343,48 +363,36 @@ sub sendmail {
$localhost = hostname() || 'localhost';
foreach $server ( @{$mailcfg{'smtp'}} ) {
# open socket needs to be inside this foreach loop on Linux,
# otherwise all servers fail if 1st one fails !??! why?
unless ( socket S, AF_INET, SOCK_STREAM, scalar(getprotobyname 'tcp') ) {
return fail("socket failed ($!)")
}
print "- trying $server\n" if $mailcfg{'debug'} > 1;
print STDERR "- trying $server\n" if $mailcfg{'debug'} > 9;
$server =~ s/\s+//go; # remove spaces just in case of a typo
# extract port if server name like "mail.domain.com:2525"
$port = ($server =~ s/:(\d+)$//o) ? $1 : $mailcfg{'port'};
$smtp = $server; # save $server for use outside foreach loop
my $smtpaddr = inet_aton $server;
unless ($smtpaddr) {
$error .= "$server not found\n";
next; # next server
# load IO::Socket SSL if needed
if ($encryption ne 'none') {
eval "require IO::Socket::SSL" || return fail("IO::Socket::SSL is not available");
}
my $retried = 0; # reset retries for each server
while ( ( not $connected = connect S, pack_sockaddr_in($port, $smtpaddr) )
and ( $retried < $mailcfg{'retries'} )
) {
$retried++;
$error .= "connect to $server failed ($!)\n";
print "- connect to $server failed ($!)\n" if $mailcfg{'debug'} > 1;
print "retrying in $mailcfg{'delay'} seconds...\n" if $mailcfg{'debug'} > 1;
sleep $mailcfg{'delay'};
if ($encryption ne 'ssl') {
$S = new IO::Socket::INET(PeerPort => $port, PeerAddr => $server, Proto => 'tcp');
}
if ( $connected ) {
print "- connected to $server\n" if $mailcfg{'debug'} > 3;
else {
$S = new IO::Socket::SSL(PeerPort => $port, PeerAddr => $server, Proto => 'tcp', SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), Domain => AF_INET);
}
if ( $S ) {
print STDERR "- connected to $server\n" if $mailcfg{'debug'} > 9;
last;
}
else {
$error .= "connect to $server failed\n";
print "- connect to $server failed, next server...\n" if $mailcfg{'debug'} > 1;
print STDERR "- connect to $server failed, next server...\n" if $mailcfg{'debug'} > 9;
next; # next server
}
}
unless ( $connected ) {
unless ( $S ) {
return fail("connect to $smtp failed ($!) no (more) retries!")
};
@ -397,8 +405,9 @@ sub sendmail {
;
}
my($oldfh) = select(S); $| = 1; select($oldfh);
$Sel = new IO::Select() || return fail("IO::Select error");
$Sel->add($S);
socket_read()
|| return fail("Connection error from $smtp on port $port ($_)");
socket_write("EHLO $localhost$CRLF")
@ -418,8 +427,37 @@ sub sendmail {
|| return fail("send HELO error (lost connection?)");
}
if ($auth) {
warn "AUTH requested\n" if ($mailcfg{debug} > 4);
# STARTTLS
if ($encryption eq 'starttls') {
defined($esmtp{'STARTTLS'})
|| return fail('STARTTLS not supported');
socket_write("STARTTLS$CRLF") || return fail("send STARTTLS error");
socket_read()
|| return fail('STARTTLS error');
IO::Socket::SSL->start_SSL($S, SSL_hostname => $server, SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE())
|| return fail("start_SSL failed");
# The client SHOULD send an EHLO command as the
# first command after a successful TLS negotiation.
socket_write("EHLO $localhost$CRLF")
|| return fail("send EHLO error (lost connection?)");
my $ehlo = socket_read();
if ($ehlo) {
# The server MUST discard any knowledge
# obtained from the client.
%esmtp = ();
# parse EHLO response
map {
s/^\d+[- ]//;
my ($k, $v) = split /\s+/, $_, 2;
$esmtp{$k} = $v || 1 if $k;
} split(/\n/, $ehlo);
}
}
if (defined($auth) && $auth->{'user'} ne '') {
warn "AUTH requested\n" if ($mailcfg{debug} > 9);
# reduce wanted methods to those supported
my @methods = grep {$esmtp{'AUTH'}=~/(^|\s)$_(\s|$)/i}
grep {$auth_support =~ /(^|\s)$_(\s|$)/i}
@ -480,9 +518,9 @@ sub sendmail {
my $challenge = socket_read()
|| return fail("AUTH DIGEST-MD5 failed: $server_reply");
$challenge =~ s/^\d+\s+//; $challenge =~ s/[\r\n]+$//;
warn "\nCHALLENGE=", decode_base64($challenge), "\n" if ($mailcfg{debug} > 10);
warn "\nCHALLENGE=", decode_base64($challenge), "\n" if ($mailcfg{debug} > 9);
my $response = _digest_md5($auth->{user}, $auth->{password}, decode_base64($challenge), $auth->{realm});
warn "\nRESPONSE=$response\n" if ($mailcfg{debug} > 10);
warn "\nRESPONSE=$response\n" if ($mailcfg{debug} > 9);
socket_write(encode_base64($response, ""), $CRLF)
|| return fail("AUTH DIGEST-MD5 failed: $server_reply");
my $status = socket_read()
@ -562,7 +600,7 @@ sub sendmail {
socket_write("QUIT$CRLF")
|| return fail("send QUIT error");
socket_read();
close S;
close $S;
return 1;
} # end sub sendmail

View File

@ -518,7 +518,14 @@ sub pandora_sendmail {
Smtp => $pa_config->{"mta_address"},
Port => $pa_config->{"mta_port"},
From => $pa_config->{"mta_from"},
Encryption => $pa_config->{"mta_encryption"},
);
# Set the timeout.
$PandoraFMS::Sendmail::mailcfg{'timeout'} = $pa_config->{"tcp_timeout"};
# Enable debugging.
$PandoraFMS::Sendmail::mailcfg{'debug'} = $pa_config->{"verbosity"};
if (defined($content_type)) {
$mail{'Content-Type'} = $content_type;
@ -535,15 +542,12 @@ sub pandora_sendmail {
$mail{auth} = {user=>$pa_config->{"mta_user"}, password=>$pa_config->{"mta_pass"}, method=>$pa_config->{"mta_auth"}, required=>1 };
}
if (sendmail %mail) {
return;
}
else {
logger ($pa_config, "[ERROR] Sending email to $to_address with subject $subject", 1);
if (defined($Mail::Sendmail::error)){
logger ($pa_config, "ERROR Code: $Mail::Sendmail::error", 5);
eval {
if (!sendmail(%mail)) {
logger ($pa_config, "[ERROR] Sending email to $to_address with subject $subject", 1);
logger ($pa_config, "ERROR Code: $Mail::Sendmail::error", 5) if (defined($Mail::Sendmail::error));
}
}
};
}
##########################################################################

View File

@ -27,7 +27,7 @@ Requires: perl(DBI) perl(DBD::mysql)
Requires: perl(HTTP::Request::Common) perl(LWP::Simple) perl(LWP::UserAgent)
Requires: perl(XML::Simple) perl(XML::Twig) net-snmp-utils
Requires: perl(NetAddr::IP) net-snmp net-tools
Requires: perl(IO::Socket::INET6) perl(Net::Telnet)
Requires: perl(IO::Socket::INET6) perl(IO::Socket::SSL) perl(Net::Telnet)
Requires: nmap sudo perl(JSON)
Requires: perl(Time::HiRes) perl(Encode::Locale)
Requires: perl perl(Sys::Syslog) perl(HTML::Entities) perl(Geo::IP)

View File

@ -24,7 +24,7 @@ Provides: %{name}-%{version}
Requires: perl-DBI perl-DBD-mysql perl-libwww-perl
Requires: perl-NetAddr-IP net-snmp net-tools perl-XML-Twig
Requires: nmap sudo perl-HTML-Tree perl-XML-Simple perl-Net-Telnet
Requires: perl-IO-Socket-INET6 perl-Socket6 snmp-mibs perl-JSON
Requires: perl-IO-Socket-INET6 perl-Socket6 perl-IO-Socket-SSL snmp-mibs perl-JSON
Requires: perl-Encode-Locale perl-Geo-IP
%description