SMTPDebug = 2;
$mail->isSMTP(); //Send using SMTP
$mail->Host = EMAIL_SETTINGS['host']; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = EMAIL_SETTINGS['username']; //SMTP username
$mail->Password = EMAIL_SETTINGS['password']; //SMTP password
$mail->SMTPSecure = EMAIL_SETTINGS['encryption']; //Enable implicit TLS encryption
$mail->Port = EMAIL_SETTINGS['port']; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom(EMAIL_SETTINGS['username'], EMAIL_SETTINGS['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" => EMAIL_SETTINGS['username'], "name" => EMAIL_SETTINGS['from_name']],
"New login to Unreal Admin Panel",
"There was a new login to the admin panel.
User: \"$user->username\"
IP: \"".$_SERVER['REMOTE_ADDR']."\""
);
}
public static function user_login_fail_notif($fail)
{
self::send_mail(
["email" => EMAIL_SETTINGS['username'], "name" => EMAIL_SETTINGS['from_name']],
"Failed login attempt - Unreal Admin Panel",
"There was a failed login attempt to the admin panel.
User: \"".$fail['login']."\"
IP: \"".$fail['IP']."\""
);
}
}