Using ob_start to email $account when user logs in

Category
drupal, php
Date Created
14th Jan 2010
Last Updated
9th Jul 2010

Using ob_start to email $account when user logs in

Question

How to email $account when user logs in

Answer


<?
function spammy_user ($op, &$edit, &$account, $category = NULL) {

	if($op=="login") {
		$to = "webmaster@zerotouch.com";
		$subject = "User Login!" . $op;
		
		ob_start();
		print_r($account);
		$mike = ob_get_clean(); 		

		$body = "Hi,\n\nYou've logged in!";
		$body .= $mike;
		mail($to, $subject, $body);
		
	} elseif ($op=="logout") {
		$to = "webmaster@zerotouch.com";
		$subject = "User Logout!" . $op;
		$body = "Hi,\n\nYou've logged out!";
		mail($to, $subject, $body);
	
	}
}
?>

Related terms