Drupal validates the email since Drupal 5; since Drupal 7, valid_email_address() (the function used to validate the email entered during registration, or when editing a user account) calls filter_var().
The code used to validate the email address doesn't check if the domain exists, the username doesn't contain typos, or the domain has an active email server. While it would be possible to check if the domain has an email server by looking at its MX records with checkdnsrr(), it would be more difficult to verify if the username is correct, as most of the SMTP hosts doesn't return a useful value for the VRFY command (which means they always return ERROR, or OK).
Notice that the documentation for getmxrr() contains the following note.
This function should not be used for the purposes of address verification. Only the mailexchangers found in DNS are returned, however, according to RFC 2821 when no mail exchangers are listed, $hostname
itself should be used as the only mail exchanger with a priority of 0.
I would rather do as @Letharion suggested, and implement hook_cron()
to get ride of those accounts created by users who didn't type their email correctly. For Drupal 7, I would use the following code.
function mymodule_cron_queue_info() {
$queues['mymodule_delete_users'] = array(
'worker callback' => 'user_delete_user',
'time' => 30,
);
return $queues;
}
function mymodule_cron() {
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
->entityCondition('entity_id', 1, '>')
->propertyCondition('access', 0)
->propertyCondition('created', REQUEST_TIME - MYMODULE_DELAY, '<')
->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
$result = $query->execute();
if (isset($result['user'])) {
$queue = DrupalQueue::get('mymodule_delete_users');
foreach (array_keys($result['user']) as $uid) {
$queue->createItem($uid);
}
}
}
The module should define the constant MYMODULE_DELAY
, and set it to an appropriate value.