From 3b4d0f43f8abad747cf35e1b482b2baa029265d4 Mon Sep 17 00:00:00 2001 From: THEPAUT Date: Thu, 20 Apr 2023 03:41:05 -0400 Subject: [PATCH] (plugin) notification::email - update (#4372) --- src/notification/email/mode/alert.pm | 39 +++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/notification/email/mode/alert.pm b/src/notification/email/mode/alert.pm index 20bea8f74..b57829a94 100644 --- a/src/notification/email/mode/alert.pm +++ b/src/notification/email/mode/alert.pm @@ -598,7 +598,7 @@ sub service_message { my $line_break = '
'; - $self->{option_results}->{service_longoutput} =~ s/\n/
/g; + $self->{option_results}->{service_longoutput} =~ s/\\n/
/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 ] );