Beispiel #1
0
 foreach ($Tools->fetch_multiple_objects("users", "role", "Administrator") as $admin) {
     if ($admin->mailNotify == "Yes") {
         $recepients[] = array("name" => $admin->real_name, "email" => $admin->email);
     }
 }
 # none?
 if (!isset($recepients)) {
     die;
 }
 # fetch mailer settings
 $mail_settings = $Tools->fetch_object("settingsMail", "id", 1);
 # fake user object, needed for create_link
 $User = new StdClass();
 @($User->settings->prettyLinks = $Scan->settings->prettyLinks);
 # initialize mailer
 $phpipam_mail = new phpipam_mail($Scan->settings, $mail_settings);
 $phpipam_mail->initialize_mailer();
 // set subject
 $subject = "phpIPAM IP state change " . date("Y-m-d H:i:s");
 //html
 $content[] = "<h3>phpIPAM host changes</h3>";
 $content[] = "<table style='margin-left:10px;margin-top:5px;width:auto;padding:0px;border-collapse:collapse;border:1px solid gray;'>";
 $content[] = "<tr>";
 $content[] = "\t<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>IP</th>";
 $content[] = "\t<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>Description</th>";
 $content[] = "\t<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>Subnet</th>";
 $content[] = "\t<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>Section</th>";
 $content[] = "\t<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>last seen</th>";
 $content[] = "\t<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>old status</th>";
 $content[] = "\t<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>new status</th>";
 $content[] = "</tr>";
Beispiel #2
0
 /**
  * Send mail on new changelog
  *
  * @access public
  * @param string $changelog
  * @return boolean
  */
 public function changelog_send_mail($changelog)
 {
     # initialize tools class
     $this->Tools = new Tools($this->Database);
     # set object
     $obj_details = $this->object_action == "add" ? $this->object_new : $this->object_old;
     # change ip_addr
     $this->object_type = str_replace("ip_addr", "address", $this->object_type);
     $this->object_type = str_replace("ip_range", "address range", $this->object_type);
     # folder
     if ($this->object_new['isFolder'] == "1" || $this->object_old['isFolder'] == "1") {
         $this->object_type = "folder";
     }
     # set subject
     $subject = string;
     if ($this->object_action == "add") {
         $subject = ucwords($this->object_type) . " create notification";
     } elseif ($this->object_action == "edit") {
         $subject = ucwords($this->object_type) . " change notification";
     } elseif ($this->object_action == "delete") {
         $subject = ucwords($this->object_type) . " delete notification";
     }
     // if address we need subnet details !
     $address_subnet = array();
     if ($this->object_type == "address") {
         $address_subnet = (array) $this->Tools->fetch_object("subnets", "id", $obj_details['subnetId']);
     }
     # set object details
     $details = string;
     if ($this->object_type == "section") {
         $details = "<a style='font-family:Helvetica, Verdana, Arial, sans-serif; font-size:12px;color:#a0ce4e;' href='" . $this->createURL() . create_link("subnets", $obj_details['id']) . "'>" . $obj_details['name'] . "(" . $obj_details['description'] . ") - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "subnet") {
         $details = "<a style='font-family:Helvetica, Verdana, Arial, sans-serif; font-size:12px;color:#a0ce4e;' href='" . $this->createURL() . create_link("subnets", $obj_details['sectionId'], $obj_details['id']) . "'>" . $this->Subnets->transform_address($obj_details['subnet'], "dotted") . "/" . $obj_details['mask'] . " (" . $obj_details['description'] . ") - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "folder") {
         $details = "<a style='font-family:Helvetica, Verdana, Arial, sans-serif; font-size:12px;color:#a0ce4e;' href='" . $this->createURL() . create_link("folder", $obj_details['sectionId'], $obj_details['id']) . "'>" . $obj_details['description'] . " - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "address") {
         $details = "<a style='font-family:Helvetica, Verdana, Arial, sans-serif; font-size:12px;color:#a0ce4e;' href='" . $this->createURL() . create_link("subnets", $address_subnet['sectionId'], $obj_details['subnetId'], "address-details", $obj_details['id']) . "'>" . $this->Subnets->transform_address($obj_details['ip_addr'], "dotted") . " ( hostname " . $obj_details['dns_name'] . ", subnet: " . $this->Subnets->transform_address($address_subnet['subnet'], "dotted") . "/" . $address_subnet['mask'] . ")- id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "address range") {
         $details = $changelog;
     }
     # set content
     $content = array();
     $content[] = "<div style='padding:10px;'>";
     $content[] = "<table>";
     $content[] = "<tr><td colspan='2'>{$this->mail_font_style}<strong>The following change was made on ipam:</strong></font></td></tr>";
     $content[] = "<tr><td colspan='2'>&nbsp;</td></tr>";
     $content[] = "<tr><td>{$this->mail_font_style} Object type:</font><td>{$this->mail_font_style}" . ucwords($this->object_type) . "</font></td></tr>";
     $content[] = "<tr><td>{$this->mail_font_style} Object details:</font><td>{$this->mail_font_style_href}" . $details . "</font></td></tr>";
     $content[] = "<tr><td>{$this->mail_font_style} User:</font><td>{$this->mail_font_style}" . $this->user->real_name . " (" . $this->user->username . ")" . "</font></td></tr>";
     $content[] = "<tr><td>{$this->mail_font_style} Action:</font><td>{$this->mail_font_style}" . $this->object_action . "</font></td></tr>";
     $content[] = "<tr><td>{$this->mail_font_style} Date:</font><td>{$this->mail_font_style}" . date("Y-m-d H:i:s") . "</font></td></tr>";
     $content[] = "<tr><td colspan='2'><hr style='height:0px;border-top:0px;border-bottom:1px solid #ddd;'></td></tr>";
     $content[] = "<tr><td style='vertical-align:top;'>{$this->mail_font_style} Changes:</td>";
     $content[] = "<td>";
     // add changelog
     $changelog = str_replace("\r\n", "<br>", $changelog);
     $changelog = array_filter(explode("<br>", $changelog));
     $content[] = "<table>";
     foreach ($changelog as $c) {
         // field
         $field = explode(":", $c);
         $value = explode("=>", $field[1]);
         // format field
         $field = trim(str_replace(array("[", "]"), "", $field[0]));
         if (is_array($this->changelog_keys[$this->object_type])) {
             if (array_key_exists($field, $this->changelog_keys[$this->object_type])) {
                 $field = $this->changelog_keys[$this->object_type][$field];
             }
         } else {
             $field = $field;
         }
         $content[] = "<tr>";
         $content[] = "  <td>{$this->mail_font_style}<strong> {$field}</strong>: </font></td>";
         $content[] = "  <td>{$this->mail_font_style} " . trim($value[0]) . " </font></td>";
         if ($this->object_action == "edit") {
             $content[] = "  <td>{$this->mail_font_style} => </font></td>";
             $content[] = "  <td>{$this->mail_font_style} " . trim($value[1]) . " </font></td>";
         }
         $content[] = "</tr>";
     }
     $content[] = "</table>";
     $content[] = "</font></td></tr>";
     $content[] = "</table>";
     $content[] = "</div>";
     # set plain content
     $content_plain = array();
     $content_plain[] = "Object type: " . $this->object_type;
     $content_plain[] = "Object details: " . $details;
     $content_plain[] = "User: "******" (" . $this->user->username . ")";
     $content_plain[] = "Action: " . $this->object_action;
     $content_plain[] = "Date: " . date("Y-m-d H:i:s");
     $content_plain[] = "\r\n--------------------\r\n";
     $content_plain[] = str_replace("<br>", "\r\n", $changelog);
     # get all admins and check who to end mail to
     //subnets, addresses - send mail to normal users also
     if ($this->object_type == "subnet" || $this->object_type == "address") {
         if ($this->object_type == "subnet") {
             $recipients = $this->changelog_mail_get_recipients($obj_details['id']);
         } else {
             $recipients = $this->changelog_mail_get_recipients($obj_details['subnetId']);
         }
     } else {
         $recipients = $this->changelog_mail_get_recipients(false);
     }
     if ($recipients === false) {
         return true;
     }
     # fetch mailer settings
     $mail_settings = $this->Tools->fetch_object("settingsMail", "id", 1);
     # initialize mailer
     $phpipam_mail = new phpipam_mail($this->settings, $mail_settings);
     $phpipam_mail->initialize_mailer();
     // set content
     $content = $phpipam_mail->generate_message(implode("\r\n", $content));
     $content_plain = implode("\r\n", $content_plain);
     # try to send
     try {
         $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName);
         foreach ($recipients as $r) {
             $phpipam_mail->Php_mailer->addAddress(addslashes(trim($r->email)));
         }
         $phpipam_mail->Php_mailer->Subject = $subject;
         $phpipam_mail->Php_mailer->msgHTML($content);
         $phpipam_mail->Php_mailer->AltBody = $content_plain;
         //send
         $phpipam_mail->Php_mailer->send();
     } catch (phpmailerException $e) {
         $this->Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
     } catch (Exception $e) {
         $this->Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
     }
     # ok
     return true;
 }
Beispiel #3
0
 /**
  * Send mail on new changelog
  *
  * @access public
  * @param mixed $changelog
  * @param int $obj_id
  * @return void
  */
 public function changelog_send_mail($changelog, $obj_id)
 {
     # initialize tools class
     $this->Tools = new Tools($this->Database);
     # set object
     $obj_details = $this->object_action == "add" ? $this->object_new : $this->object_old;
     # change ip_addr
     $this->object_type = str_replace("ip_addr", "address", $this->object_type);
     $this->object_type = str_replace("ip_range", "address range", $this->object_type);
     # folder
     if ($this->object_new['isFolder'] == "1" || $this->object_old['isFolder'] == "1") {
         $this->object_type = "folder";
     }
     # set subject
     if ($this->object_action == "add") {
         $subject = ucwords($this->object_type) . " create notification";
     } elseif ($this->object_action == "edit") {
         $subject = ucwords($this->object_type) . " change notification";
     } elseif ($this->object_action == "delete") {
         $subject = ucwords($this->object_type) . " delete notification";
     }
     // if address we need subnet details !
     if ($this->object_type == "address") {
         $address_subnet = (array) $this->Tools->fetch_object("subnets", "id", $obj_details['subnetId']);
     }
     # set object details
     if ($this->object_type == "section") {
         $details = "<a href='" . $this->createURL() . create_link("subnets", $obj_details['id']) . "'>" . $obj_details['name'] . "(" . $obj_details['description'] . ") - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "subnet") {
         $details = "<a href='" . $this->createURL() . create_link("subnets", $obj_details['sectionId'], $obj_details['id']) . "'>" . $this->Subnets->transform_address($obj_details['subnet'], "dotted") . "/" . $obj_details['mask'] . " (" . $obj_details['description'] . ") - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "folder") {
         $details = "<a href='" . $this->createURL() . create_link("folder", $obj_details['sectionId'], $obj_details['id']) . "'>" . $obj_details['description'] . " - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "address") {
         $details = "<a href='" . $this->createURL() . create_link("subnets", $address_subnet['sectionId'], $obj_details['subnetId'], "address-details", $obj_details['id']) . "'>" . $this->Subnets->transform_address($obj_details['ip_addr'], "dotted") . " ( hostname " . $obj_details['dns_name'] . ", subnet: " . $this->Subnets->transform_address($address_subnet['subnet'], "dotted") . "/" . $address_subnet['mask'] . ")- id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "address range") {
         $details = $changelog;
     }
     # set content
     $style = "face='Helvetica, Verdana, Arial, sans-serif' style='font-size:13px;'";
     $content[] = "<div style='padding:10px;'>";
     $content[] = "<table>";
     $content[] = "<tr><td><font {$style}>Object type:</font><td><font {$style}>" . $this->object_type . "</font></td></tr>";
     $content[] = "<tr><td><font {$style}>Object details:</font><td><font {$style}>" . $details . "</font></td></tr>";
     $content[] = "<tr><td><font {$style}>User:</font><td><font {$style}>" . $this->user->real_name . " (" . $this->user->username . ")" . "</font></td></tr>";
     $content[] = "<tr><td><font {$style}>Action:</font><td><font {$style}>" . $this->object_action . "</font></td></tr>";
     $content[] = "<tr><td><font {$style}>Date:</font><td><font {$style}>" . date("Y-m-d H:i:s") . "</font></td></tr>";
     $content[] = "<tr><td colspan='2'><hr></td></tr>";
     $content[] = "<tr><td colspan='2'><font {$style}>Changes:<br>";
     $content[] = "<tr><td colspan='2'><font {$style}>&nbsp;<br>";
     $changelog = str_replace("\r\n", "<br>", $changelog);
     $content[] = "{$changelog}</font></td></tr>";
     $content[] = "</table>";
     $content[] = "</div>";
     # set plain content
     $content_plain[] = "Object type: " . $this->object_type;
     $content_plain[] = "Object details: " . $details;
     $content_plain[] = "User: "******" (" . $this->user->username . ")";
     $content_plain[] = "Action: " . $this->object_action;
     $content_plain[] = "Date: " . date("Y-m-d H:i:s");
     $content_plain[] = "\r\n--------------------\r\n";
     $content_plain[] = str_replace("<br>", "\r\n", $changelog);
     # get all admins and check who to end mail to
     $recipients = $this->changelog_mail_get_recipients();
     if ($recipients === false) {
         return true;
     }
     # fetch mailer settings
     $mail_settings = $this->Tools->fetch_object("settingsMail", "id", 1);
     # initialize mailer
     $phpipam_mail = new phpipam_mail($this->settings, $mail_settings);
     $phpipam_mail->initialize_mailer();
     // set content
     $content = $phpipam_mail->generate_message(implode("\r\n", $content));
     $content_plain = implode("\r\n", $content_plain);
     # try to send
     try {
         $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName);
         foreach ($recipients as $r) {
             $phpipam_mail->Php_mailer->addAddress(addslashes(trim($r->email)));
         }
         $phpipam_mail->Php_mailer->Subject = $subject;
         $phpipam_mail->Php_mailer->msgHTML($content);
         $phpipam_mail->Php_mailer->AltBody = $content_plain;
         //send
         $phpipam_mail->Php_mailer->send();
     } catch (phpmailerException $e) {
         $this->Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
     } catch (Exception $e) {
         $this->Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
     }
     # ok
     return true;
 }
Beispiel #4
0
 /**
  * Sends mail for IP request
  *
  * @access public
  * @param string $action (default: "new")
  * @param mixed $values
  * @return void
  */
 public function ip_request_send_mail($action = "new", $values)
 {
     # get all admins and check who to end mail to
     $recipients = $this->ip_request_get_mail_recipients();
     # add requester to cc
     $recipients_requester = $values['requester'];
     # reformat key / vaues
     $values = $this->ip_request_reformat_mail_values($values);
     #reformat empty
     $values = $this->reformat_empty_array_fields($values, "/");
     # generate content
     if ($action == "new") {
         $subject = "New IP address request";
     } elseif ($action == "accept") {
         $subject = "IP address request accepted";
     } elseif ($action == "reject") {
         $subject = "IP address request rejected";
     } else {
         $this->Result->show("danger", _("Invalid request action"), true);
     }
     // set html content
     $content[] = "<table style='margin-left:10px;margin-top:5px;width:auto;padding:0px;border-collapse:collapse;'>";
     $content[] = "<tr><td colspan='2' style='padding:5px;margin:0px;color:#333;font-size:16px;text-shadow:1px 1px 1px white;border-bottom:1px solid #eeeeee;'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:16px;'>{$subject}</font></td></tr>";
     foreach ($values as $k => $v) {
         // title search
         if (preg_match("/s_title_/", $k)) {
             $content[] = "<tr><td colspan='2' style='padding:5px;margin:0px;color:#333;font-size:16px;text-shadow:1px 1px 1px white;border-bottom:1px solid #eeeeee;'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:16px;'>{$v}</font></td></tr>";
         } else {
             //content
             $content[] = "<tr>";
             $content[] = "<td style='padding:3px;padding-left:15px;margin:0px;'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:13px;'>{$k}</font></td>";
             $content[] = "<td style='padding:3px;padding-left:15px;margin:0px;'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:13px;'>{$v}</font></td>";
             $content[] = "</tr>";
         }
     }
     $content[] = "<tr><td style='padding:5px;padding-left:15px;margin:0px;font-style:italic;padding-bottom:3px;text-align:right;color:#ccc;text-shadow:1px 1px 1px white;border-top:1px solid white;'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:11px;'>Sent by user " . $User->user->real_name . " at " . date('Y/m/d H:i') . "</font></td></tr>";
     //set alt content
     $content_plain[] = "{$subject}" . "\r\n------------------------------\r\n";
     foreach ($values as $k => $v) {
         $content_plain[] = $k . " => " . $v;
     }
     $content_plain[] = "\r\n\r\n" . _("Sent by user") . " " . $User->user->real_name . " at " . date('Y/m/d H:i');
     $content[] = "</table>";
     # fetch mailer settings
     $mail_settings = $this->fetch_object("settingsMail", "id", 1);
     # initialize mailer
     $this->get_settings();
     $phpipam_mail = new phpipam_mail($this->settings, $mail_settings);
     $phpipam_mail->initialize_mailer();
     // set content
     $content = $phpipam_mail->generate_message(implode("\r\n", $content));
     $content_plain = implode("\r\n", $content_plain);
     # try to send
     try {
         $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName);
         if ($recipients !== false) {
             foreach ($recipients as $r) {
                 $phpipam_mail->Php_mailer->addAddress(addslashes(trim($r->email)));
             }
             $phpipam_mail->Php_mailer->AddCC(addslashes(trim($recipients_requester)));
         } else {
             $phpipam_mail->Php_mailer->addAddress(addslashes(trim($recipients_requester)));
         }
         $phpipam_mail->Php_mailer->Subject = $subject;
         $phpipam_mail->Php_mailer->msgHTML($content);
         $phpipam_mail->Php_mailer->AltBody = $content_plain;
         //send
         $phpipam_mail->Php_mailer->send();
     } catch (phpmailerException $e) {
         $Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
     } catch (Exception $e) {
         $Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
     }
     # ok
     return true;
 }
Beispiel #5
0
 *	Mail settings
 **************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
require dirname(__FILE__) . '/../../../functions/classes/class.Mail.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# fetch mailer settings
$mail_settings = $Admin->fetch_object("settingsMail", "id", 1);
# initialize mailer
$phpipam_mail = new phpipam_mail($User->settings, $mail_settings);
//override settings
$phpipam_mail->override_settings($_POST);
//create object
$phpipam_mail->initialize_mailer();
# set content
$content = $phpipam_mail->generate_message("phpIPAM test HTML message");
$content_plain = "phpIPAM test text message";
# try to send
try {
    $phpipam_mail->Php_mailer->setFrom($_POST['mAdminMail'], $_POST['mAdminName']);
    $phpipam_mail->Php_mailer->addAddress($User->settings->siteAdminMail, $User->settings->siteAdminName);
    $phpipam_mail->Php_mailer->Subject = 'phpIPAM localhost mail test';
    $phpipam_mail->Php_mailer->msgHTML($content);
    $phpipam_mail->Php_mailer->AltBody = $content_plain;
    //send
 /**
  * Checks if subnet usage is over threshold and sends alert
  *
  * @access private
  * @param mixed $address
  * @return void
  */
 private function threshold_check($address)
 {
     $address = (object) $address;
     $content = array();
     $content_plain = array();
     # fetch settings
     $this->get_settings();
     # enabled ?
     if ($this->settings->enableThreshold == "1") {
         # object
         if (!is_object($this->Subnets)) {
             $this->Subnets = new Subnets($this->Database);
         }
         # fetch subnet
         $subnet = $this->Subnets->fetch_subnet("id", $address->subnetId);
         # threshold set ?
         if ($subnet->threshold > 0) {
             # count number of hosts in subnet
             $used_hosts = $this->count_subnet_addresses($address->subnetId);
             # calculate subnet usage
             $subnet_usage = $this->Subnets->calculate_subnet_usage($used_hosts, $subnet->mask, $subnet->subnet, $subnet->isFull);
             # if over send mail
             if (gmp_strval(gmp_sub(100, (int) round($subnet_usage['freehosts_percent'], 0))) > $subnet->threshold) {
                 // fetch mail settings
                 $Tools = new Tools($this->Database);
                 $admins = $Tools->fetch_multiple_objects("users", "role", "Administrator");
                 // if some recipients
                 if ($admins !== false) {
                     // mail settings
                     $mail_settings = $Tools->fetch_object("settingsMail", "id", 1);
                     // mail class
                     $phpipam_mail = new phpipam_mail($this->settings, $mail_settings);
                     // send
                     $phpipam_mail->initialize_mailer();
                     // set parameters
                     $subject = "Subnet threshold limit reached" . " (" . $this->transform_address($subnet->subnet, "dotted") . "/" . $subnet->mask . ")";
                     $content[] = "<table style='margin-left:10px;margin-top:5px;width:auto;padding:0px;border-collapse:collapse;'>";
                     $content[] = "<tr><td style='padding:5px;margin:0px;color:#333;font-size:16px;text-shadow:1px 1px 1px white;border-bottom:1px solid #eeeeee;' colspan='2'>{$this->mail_font_style}<strong>{$subject}</font></td></tr>";
                     $content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;">' . $this->mail_font_style . '' . _('Subnet') . '</a></font></td>	<td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;padding-top:10px;"><a href="' . $this->createURL() . '' . create_link("subnets", $subnet->sectionId, $subnet->id) . '">' . $this->mail_font_style_href . $this->transform_address($subnet->subnet, "dotted") . "/" . $subnet->mask . '</font></a></td></tr>';
                     $content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;">' . $this->mail_font_style . '' . _('Description') . '</font></td>	  	<td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;">' . $this->mail_font_style . '' . $subnet->description . '</font></td></tr>';
                     $content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;">' . $this->mail_font_style . '' . _('Usage') . ' (%)</font></td>	<td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;">' . $this->mail_font_style . '' . gmp_strval(gmp_sub(100, (int) round($subnet_usage['freehosts_percent'], 0))) . '</font></td></tr>';
                     $content[] = "</table>";
                     // plain
                     $content_plain[] = "{$subject}" . "\r\n------------------------------\r\n";
                     $content_plain[] = _("Subnet") . ": " . $this->transform_address($subnet->subnet, "dotted") . "/" . $subnet->mask;
                     $content_plain[] = _("Usage") . " (%) : " . gmp_strval(gmp_sub(100, (int) round($subnet_usage['freehosts_percent'], 0)));
                     # set content
                     $content = $phpipam_mail->generate_message(implode("\r\n", $content));
                     $content_plain = implode("\r\n", $content_plain);
                     # try to send
                     try {
                         $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName);
                         //add all admins to CC
                         $recipients = $this->changelog_mail_get_recipients($subnet->id);
                         if ($recipients !== false) {
                             foreach ($recipients as $a) {
                                 $phpipam_mail->Php_mailer->addAddress($a->email);
                             }
                             $phpipam_mail->Php_mailer->Subject = $subject;
                             $phpipam_mail->Php_mailer->msgHTML($content);
                             $phpipam_mail->Php_mailer->AltBody = $content_plain;
                             //send
                             $phpipam_mail->Php_mailer->send();
                         } else {
                             return true;
                         }
                     } catch (phpmailerException $e) {
                         $this->Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
                     } catch (Exception $e) {
                         $this->Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
                     }
                 }
             }
         } else {
             return true;
         }
     } else {
         return true;
     }
 }