From 5cf9d70c6f57ccc00ef383e5b36a00de3be7d2cd Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Thu, 11 Jan 2024 09:58:06 -0600 Subject: [PATCH] Add config token for mail_subject_encoding --- pandora_server/conf/pandora_server.conf.new | 2 ++ pandora_server/lib/PandoraFMS/Config.pm | 5 +++++ pandora_server/lib/PandoraFMS/Tools.pm | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index bddb11a293..1945cbd08f 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -816,3 +816,5 @@ madeserver_autofit 7d # Model sensitivity. A lower value triggers less anomalies (PANDORA FMS ENTERPRISE ONLY). madeserver_sensitivity 0.1 +# Encoding to use on mail subject (MIME-Header by default) +# mail_subject_encoding MIME-Header-ISO_2022_JP \ No newline at end of file diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 4f45c28b19..4b7a6c142a 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -589,6 +589,8 @@ sub pandora_load_config { $pa_config->{"madeserver"} = 0; # 774. + $pa_config->{"mail_subject_encoding"} = 'MIME-Header'; # 776. + # Check for UID0 if ($pa_config->{"quiet"} != 0){ if ($> == 0){ @@ -691,6 +693,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^mail_in_separate\s+([0-9]*)/i) { $pa_config->{'mail_in_separate'}= clean_blank($1); } + elsif ($parametro =~ m/^mail_subject_encoding\s(.*)/i) { + $pa_config->{'mail_subject_encoding'}= clean_blank($1); + } elsif ($parametro =~ m/^snmp_logfile\s(.*)/i) { $pa_config->{'snmp_logfile'}= clean_blank($1); } diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 580344542c..543ea45556 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -748,6 +748,7 @@ sub pandora_sendmail { my $subject = $_[2]; my $message = $_[3]; my $content_type = $_[4]; + my $encoding = $pa_config->{"mail_subject_encoding"} || 'MIME-Header'; $subject = decode_entities ($subject); @@ -758,7 +759,7 @@ sub pandora_sendmail { my %mail = ( To => $to_address, Message => $message, - Subject => encode('MIME-Header', $subject), + Subject => encode($encoding, $subject), 'X-Mailer' => $pa_config->{"rb_product_name"}, Smtp => $pa_config->{"mta_address"}, Port => $pa_config->{"mta_port"},