Rate this article

Send me and a notification email when someone logs into my site

Rating: 5.0/5 (3 votes cast)

To get you site to send you an automated login notification when someone logs in you need to add a "Custom Trigger" of the after type to the Login SB.

Simply copy and paste this code and change to suit your needs.

$activate_notification = "Y"; // set to "N" or "" to deactivate this temporarily
if ($activate_notification == "Y") {// start notification activation check
if ($_SESSION['kt_login_id'] != "1") { //Decide who not to report usually the super admin
// Set Detail
$who_logged_in_name = $_SESSION['kt_name']; // will later be displayed in the emailīs body
$who_logger_in_surname = $_SESSION['kt_surname']; // will later be displayed in the emailīs body
$when = date('l dS \of F Y H:i');

// subject
$subject = 'Basic Site Login';

// start message
$message = '
<html>
<head>
  <title>Site Login</title>
</head>
<body>

  <p>'.$when. '</p>
  <p>' .$who_logged_in_name.' '.$who_logger_in_surname. ' just logged in.</p>


</body>
</html>
';
// end message
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Site Owner <address1@mydomain.com>' . "\r\n";
$headers .= 'From: Auto Report <address2@mydomain.com>' . "\r\n";
$headers .= 'Cc: address3@mydomain.com' . "\r\n";
$headers .= 'Bcc: address4@mydomain.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
} // end notification part
} // end notification activation check


Adobe

ionCube Online PHP Encoder
XMS Systems
Free PositiveSSL and WhoisGuard with Every Domain Purchase

Although we try to ensure all the articles submitted are valid it is your responsibility to make sure you have backups before you use these suggestions on your pc or websites.
We do not take any responsibility for any data-loss, loss in functionality or any problem that might arise in what-ever way or form by making use of the information on this site.

"Friends of Interakt" has no connection to the Adobe Interakt Company