mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix: Validate email addresses used in alerting (#7830)
* fix: Validate email addresses used in alerting * Whitespace
This commit is contained in:
committed by
Tony Murray
parent
e3082873f6
commit
edf26c1106
@@ -233,6 +233,7 @@ function RunRules($device)
|
||||
function GetContacts($results)
|
||||
{
|
||||
global $config, $authorizer;
|
||||
|
||||
if (sizeof($results) == 0) {
|
||||
return array();
|
||||
}
|
||||
@@ -306,6 +307,16 @@ function GetContacts($results)
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($tmp_contacts)) {
|
||||
// Validate contacts so we can fall back to default if configured.
|
||||
$mail = new PHPMailer();
|
||||
foreach ($tmp_contacts as $tmp_email => $tmp_name) {
|
||||
if ($mail->validateAddress($tmp_email) != true) {
|
||||
unset($tmp_contacts[$tmp_email]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Send email to default contact if no other contact found
|
||||
if ((count($tmp_contacts) == 0) && ($config['alert']['default_if_none']) && (!empty($config['alert']['default_mail']))) {
|
||||
$tmp_contacts[$config['alert']['default_mail']] = 'NOC';
|
||||
|
Reference in New Issue
Block a user