SMTPDebug = 2; $mail->isSMTP(); // Send using SMTP $mail->Host = get_config("smtp::host"); // Set the SMTP server to send through $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = get_config("smtp::username"); // SMTP username $mail->Password = get_config("smtp::password"); // SMTP password $mail->SMTPSecure = get_config("smtp::encryption"); // Enable implicit TLS encryption $mail->Port = get_config("smtp::port"); // TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` //Recipients $mail->setFrom(get_config("smtp::username"), get_config("smtp::from_name")); $mail->addAddress($to['email'], $to['name']); // Add a recipient //Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = $subject; $mail->Body = $body . "

Thank you for using UnrealIRCd!"; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); } catch (Exception $e) { die("Could not send mail:". $e); } } /** * Send a login notification to the admin (note-to-self) * @param mixed $user * @return void */ public static function user_login_notif($user) { self::send_mail( ["email" => get_config("smtp::username"), "name" => get_config("smtp::from_name")], "New login to Unreal Admin Panel", "There was a new login to the admin panel.
User: \"$user->username\"
IP: \"".$_SERVER['REMOTE_ADDR']."\" (".$_SERVER['HTTP_CF_IPCOUNTRY'].")
". "User Agent: ".$_SERVER['HTTP_USER_AGENT'] ); if ($user->email) self::send_mail( ["email" => $user->email, "name" => $user->first_name . " " . $user->last_name], "New login to your account", "Dear $user->first_name,

". "There was a new login to account: \"$user->username\"

". "Details:
". "IP: ".$_SERVER['REMOTE_ADDR']." (".$_SERVER['HTTP_CF_IPCOUNTRY'].")
". "User Agent: ".$_SERVER['HTTP_USER_AGENT']."

". "If this was not you, please contact your Panel Administrator." ); } /** * Send a notification about the failed attempt */ public static function user_login_fail_notif($fail) { self::send_mail( ["email" => get_config("smtp::username"), "name" => get_config("smtp::from_name")], "Failed login attempt - Unreal Admin Panel", "-- ADMIN NOTIFICATION --,

". "There was failed login attempt to account: \"$user->username\"

". "Details:
". "IP: ".$_SERVER['REMOTE_ADDR']." (".$_SERVER['HTTP_CF_IPCOUNTRY'].")
". "User Agent: ".$_SERVER['HTTP_USER_AGENT']."

" ); $user = new PanelUser($fail['login']); if ($user->email) self::send_mail( ["email" => $user->email, "name" => $user->first_name . " " . $user->last_name], "Failed login attempt to your account", "Dear $user->first_name,

". "There was failed login attempt to your account: \"$user->username\"

". "Details:
". "IP: ".$_SERVER['REMOTE_ADDR']." (".$_SERVER['HTTP_CF_IPCOUNTRY'].")
". "User Agent: ".$_SERVER['HTTP_USER_AGENT']."

". "If this was not you, please contact your Panel Administrator." ); } public static function navbar_hook(&$pages) { $page_name = "Mail"; $page_link = "plugins/php_mailer/mail-settings.php"; $pages["Settings"][$page_name] = ["script" => $page_link]; } }