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

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

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
divider

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 emails body
   $who_logger_in_surname = $_SESSION['kt_surname']; // will later be displayed in the emails body
   $when = date('l dS \of F Y H:i');

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

   // 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
Written by:  - 27 Oct, 2009