I would be nice if the first check was loaded into the db. Once should be enough unless changes are made. Preferably at profile update or new register. Carl McDade budda wrote:
Project: Drupal Version: 4.5.2 Component: user.module Category: feature requests Priority: normal Assigned to: Anonymous Reported by: budda Updated by: budda Status: patch
it *may* be more helpful to move the MX record checking in to the common valid_email_address() function instead? This would ensure other modules validating email addresses could gain the same functionality.
budda
Previous comments: ------------------------------------------------------------------------
February 23, 2005 - 01:26 : budda
Working with the user.module of 4.5.2 distribution I amended the user_validate_mail() function to provide additional checking for a new user. This was inspired by the constant bounced emails I was getting each day from new users mistyping their email address. Sorry that the code is not in patch form. The following code should be placed in user.module :- function _user_check_dnsrr($maildomain, $rectype = 'MX') { if(!empty($maildomain)) { if(function_exists('checkdnsrr')) { return checkdnsrr($maildomain, $rectype); } else { exec("nslookup -type=$rectype $maildomain", $result); foreach ($result as $line) { if(eregi("^$maildomain",$line)) { return true; } } return false; } } return false; } function user_validate_mail($mail) { if (!$mail) return t('You must enter an e-mail address.'); list($username, $maildomain) = split("@", $mail); if (!valid_email_address($mail) || !_user_check_dnsrr($maildomain, "MX")) { return t('The e-mail address %mail is not valid.', array('%mail' => "<em>$mail</em>")); } } I have been using the above on http://www.bargainspy.co.uk/user/register without problem for a day now. Another step in the direction of helping users hide their general stupidity!