(plugin) notification::email - update (#4372)

This commit is contained in:
THEPAUT 2023-04-20 03:41:05 -04:00 committed by David Boucher
parent 65c111d91f
commit 3b4d0f43f8
1 changed files with 24 additions and 15 deletions

View File

@ -598,7 +598,7 @@ sub service_message {
my $line_break = '<br />';
$self->{option_results}->{service_longoutput} =~ s/\n/<br \/>/g;
$self->{option_results}->{service_longoutput} =~ s/\\n/<br \/>/g;
$self->{payload_attachment}->{subject} = '*** ' . $self->{option_results}->{type} . ' : ' . $self->{option_results}->{service_description} . ' '. $self->{option_results}->{service_state} . ' on ' . $self->{option_results}->{host_name} . ' ***';
$self->{payload_attachment}->{alt_message} = '
@ -954,6 +954,22 @@ sub run {
);
}
my $html_part = Email::MIME->create(
attributes => {
content_type => 'text/html',
charset => 'UTF-8'
},
body => $self->{payload_attachment}->{html_message}
);
my $text_part = Email::MIME->create(
attributes => {
content_type => 'text/plain',
charset => 'UTF-8'
},
body => $self->{payload_attachment}->{alt_message}
);
my $email = Email::MIME->create(
header_str => [
From => $self->{option_results}->{from_address},
@ -962,20 +978,13 @@ sub run {
],
parts => [
Email::MIME->create(
attributes => {
content_type => 'text/plain',
charset => 'UTF-8'
},
body => $self->{payload_attachment}->{alt_message}
),
Email::MIME->create(
attributes => {
content_type => 'text/html',
charset => 'UTF-8'
},
body => $self->{payload_attachment}->{html_message}
),
$attachement
attributes => {
content_type => 'multipart/alternative',
charset => 'UTF-8',
},
parts => [$text_part, $html_part],
),
$attachement
]
);