enh(plugin): update email notification mode (#4520)
This commit is contained in:
parent
f9c88eac95
commit
ad32fcdf29
|
@ -263,6 +263,7 @@ sub host_message {
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
|
background-color: #F2F2F2;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
|
@ -360,9 +361,6 @@ sub host_message {
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
||||||
<!--[if !mso]><!-->
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Red+Hat+Display
|
|
||||||
</head>
|
</head>
|
||||||
<body width="100%" bgcolor="#f6f6f6" style="margin: 0;line-height:1.4;padding:0;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;">
|
<body width="100%" bgcolor="#f6f6f6" style="margin: 0;line-height:1.4;padding:0;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;">
|
||||||
<center style="width: 100%; background: #f6f6f6; text-align: left;">
|
<center style="width: 100%; background: #f6f6f6; text-align: left;">
|
||||||
|
@ -641,6 +639,7 @@ sub service_message {
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
|
background-color: #F2F2F2;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
|
@ -738,9 +737,6 @@ sub service_message {
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
||||||
<!--[if !mso]><!-->
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Red+Hat+Display
|
|
||||||
</head>
|
</head>
|
||||||
<body width="100%" bgcolor="#f6f6f6" style="margin: 0;line-height:1.4;padding:0;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;">
|
<body width="100%" bgcolor="#f6f6f6" style="margin: 0;line-height:1.4;padding:0;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;">
|
||||||
<center style="width: 100%; background: #f6f6f6; text-align: left;">
|
<center style="width: 100%; background: #f6f6f6; text-align: left;">
|
||||||
|
@ -863,10 +859,6 @@ sub service_message {
|
||||||
<tr>
|
<tr>
|
||||||
<td width="98%" style="vertical-align:middle;font-size:14px;width:98%;margin:0 10px 0 10px;">
|
<td width="98%" style="vertical-align:middle;font-size:14px;width:98%;margin:0 10px 0 10px;">
|
||||||
<h4 style="font-family: CoconPro-BoldCond, Open Sans, Verdana, sans-serif; margin:0; font-size:15px; color:#b0b0b0; padding-left:3%;text-decoration:underline;">Service Graph:</h4>
|
<h4 style="font-family: CoconPro-BoldCond, Open Sans, Verdana, sans-serif; margin:0; font-size:15px; color:#b0b0b0; padding-left:3%;text-decoration:underline;">Service Graph:</h4>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
'. $img . '
|
'. $img . '
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -937,22 +929,6 @@ sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->set_payload();
|
$self->set_payload();
|
||||||
my $attachement = '';
|
|
||||||
if (defined($self->{payload_attachment}->{png}) && $self->{payload_attachment}->{png} ne '' && $self->{payload_attachment}->{png} ne 'Resource not found' ) {
|
|
||||||
my $img_cid = $self->{option_results}->{host_name} . '_' . $self->{option_results}->{service_description};
|
|
||||||
$attachement = Email::MIME->create(
|
|
||||||
header_str => [
|
|
||||||
'Content-ID' => "<$img_cid>"
|
|
||||||
],
|
|
||||||
attributes => {
|
|
||||||
content_type => 'image/png',
|
|
||||||
disposition => 'inline',
|
|
||||||
encoding => 'base64',
|
|
||||||
name => $self->{option_results}->{host_name} . ' - ' . $self->{option_results}->{service_description} . '.png'
|
|
||||||
},
|
|
||||||
body => $self->{payload_attachment}->{png}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
my $html_part = Email::MIME->create(
|
my $html_part = Email::MIME->create(
|
||||||
attributes => {
|
attributes => {
|
||||||
|
@ -970,7 +946,12 @@ sub run {
|
||||||
body => $self->{payload_attachment}->{alt_message}
|
body => $self->{payload_attachment}->{alt_message}
|
||||||
);
|
);
|
||||||
|
|
||||||
my $email = Email::MIME->create(
|
my $email;
|
||||||
|
|
||||||
|
if (defined($self->{payload_attachment}->{png}) && $self->{payload_attachment}->{png} ne '' && $self->{payload_attachment}->{png} ne 'Resource not found' ) {
|
||||||
|
my $img_cid = $self->{option_results}->{host_name} . '_' . $self->{option_results}->{service_description};
|
||||||
|
|
||||||
|
$email = Email::MIME->create(
|
||||||
header_str => [
|
header_str => [
|
||||||
From => $self->{option_results}->{from_address},
|
From => $self->{option_results}->{from_address},
|
||||||
To => $self->{option_results}->{to_address},
|
To => $self->{option_results}->{to_address},
|
||||||
|
@ -984,9 +965,34 @@ sub run {
|
||||||
},
|
},
|
||||||
parts => [$text_part, $html_part],
|
parts => [$text_part, $html_part],
|
||||||
),
|
),
|
||||||
$attachement
|
Email::MIME->create(
|
||||||
|
header_str => [
|
||||||
|
'Content-ID' => "<$img_cid>"
|
||||||
|
],
|
||||||
|
attributes => {
|
||||||
|
content_type => 'image/png',
|
||||||
|
disposition => 'inline',
|
||||||
|
encoding => 'base64',
|
||||||
|
name => $self->{option_results}->{host_name} . ' - ' . $self->{option_results}->{service_description} . '.png'
|
||||||
|
},
|
||||||
|
body => $self->{payload_attachment}->{png}
|
||||||
|
)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$email = Email::MIME->create(
|
||||||
|
header_str => [
|
||||||
|
From => $self->{option_results}->{from_address},
|
||||||
|
To => $self->{option_results}->{to_address},
|
||||||
|
Subject => $self->{payload_attachment}->{subject}
|
||||||
|
],
|
||||||
|
attributes => {
|
||||||
|
content_type => 'multipart/alternative',
|
||||||
|
charset => 'UTF-8',
|
||||||
|
},
|
||||||
|
parts => [$text_part, $html_part],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
my $smtp = Email::Sender::Transport::SMTP->new({
|
my $smtp = Email::Sender::Transport::SMTP->new({
|
||||||
host => $self->{option_results}->{smtp_address},
|
host => $self->{option_results}->{smtp_address},
|
||||||
|
|
Loading…
Reference in New Issue