Allowing only accounts to register

I want to allow registrations only with and email accounts, to reduce spam.

So, I added this piece of coding in my elgg/actions/register.php file:

list($un, $isp) =explode("@", $password);



if ((strcmp($isp,$gmail) != 0) && (strcmp($isp,$hotmail) != 0)) {

throw new RegistrationException(elgg_echo('RegistrationException:EmailMismatch'));


yet, when I log in with my testing account, it still throws me the exception...

what am I doing wrong?