3 use PHPMailer\PHPMailer\PHPMailer
;
4 use PHPMailer\PHPMailer\SMTP
;
8 public $name = "PHPMailer()";
9 public $author = "Valware";
10 public $version = "1.0";
11 public $description = "Send mail using PHPMailer()";
12 public $email = "v.a.pond@outlook.com";
14 function __construct()
16 Hook
::func(HOOKTYPE_USER_LOGIN
, 'php_mailer::user_login_notif');
17 Hook
::func(HOOKTYPE_USER_LOGIN_FAIL
, 'php_mailer::user_login_fail_notif');
20 public static function send_mail($to, $subject, $body)
22 $mail = new PHPMailer(true);
25 //$mail->SMTPDebug = 2;
26 $mail->isSMTP(); //Send using SMTP
27 $mail->Host
= EMAIL_SETTINGS
['host']; //Set the SMTP server to send through
28 $mail->SMTPAuth
= true; //Enable SMTP authentication
29 $mail->Username
= EMAIL_SETTINGS
['username']; //SMTP username
30 $mail->Password
= EMAIL_SETTINGS
['password']; //SMTP password
31 $mail->SMTPSecure
= EMAIL_SETTINGS
['encryption']; //Enable implicit TLS encryption
32 $mail->Port
= EMAIL_SETTINGS
['port']; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
35 $mail->setFrom(EMAIL_SETTINGS
['username'], EMAIL_SETTINGS
['from_name']);
36 $mail->addAddress($to['email'], $to['name']); //Add a recipient
39 $mail->isHTML(true); //Set email format to HTML
40 $mail->Subject
= $subject;
41 $mail->Body
= $body . "<br><br>Thank you for using UnrealIRCd!";
42 $mail->AltBody
= 'This is the body in plain text for non-HTML mail clients';
45 } catch (Exception
$e) {
46 die("Could not send mail:". $e);
51 * Send a login notification to the admin (note-to-self)
55 public static function user_login_notif($user)
58 ["email" => EMAIL_SETTINGS
['username'], "name" => EMAIL_SETTINGS
['from_name']],
59 "New login to Unreal Admin Panel",
60 "There was a new login to the admin panel.<br>User: \"$user->username\"<br>IP: \"".$_SERVER['REMOTE_ADDR']."\""
63 public static function user_login_fail_notif($fail)
66 ["email" => EMAIL_SETTINGS
['username'], "name" => EMAIL_SETTINGS
['from_name']],
67 "Failed login attempt - Unreal Admin Panel",
68 "There was a failed login attempt to the admin panel.<br>User: \"".$fail['login']."\"<br>IP: \"".$fail['IP']."\""