Send alert email when a user effect login
Hello,
I need to create this behaviour with "Send Email" of DataBridge (installed 2.3.2 version):
1) login page;
2) send an email to the administrator when a user effect login (with the user's details in the email, included the IP address).
Now I've tried to create this "send email" (see the code below) in the login page but works only if the page not redirect (so the user after clicking "login in", remain in the same page... which also generates a wrong behaviour sending the email every time the user refresh the page).
Is possible to send an email when the user is redirect to the starting restricted page?
Also, how can I include the user's IP address in the email?
---------
---------
<?php
if (WA_Auth_RulePasses("Logged in to pcms2_users")) { //WA Universal Email
$Email = new WA_Email("login_2");
$Email->From = "test@test.com";
$Email->Method = "smtp";
$Email->Host = "mail.test.com";
$Email->Port = "587";
$Email->SMTPAuth = true;
$Email->SMTPSecure = "tls";
$Email->Username = "test@test.com";
$Email->Password = "password";
$Email->addTo("test@test.com");
$Email->BodyFile = "../../../webassist/email/templates/waue_login.php";
if (function_exists("rel2abs") && $Email->Redirect) $Email->Redirect = $Email->Redirect?rel2abs($Email->Redirect,dirname(__FILE__)):"";
for ($emailGroup=0; $emailGroup<sizeof($Email->To); $emailGroup++) {
$Email->Subject = "Subject email";
$Email->send($emailGroup);
}
$Email->close();
}
?>
---------
---------