On some setups (like Windows, ehem) the checkdnsrr and getmxrr functions do not exist. So I've stuck in a function_exists on these.

Files: 
CommentFileSizeAuthor
email_verify.module.patch1019 bytesTimotheos

Comments

Confirmed re. windows (use a proper OS!):
http://php.net/checkdnsrr
http://php.net/getmxrr

Anyway, wouldn't bypassing those two if statements seriously impair the functionality on windows servers?

Title:checkdnsrr and getmxrr error function does not existcheckdnsrr and getmxrr error function does not exist module does not verify email
Version:4.7.x-1.0» 4.6.x-1.0
Priority:Normal» Critical

I install the email_verify module for version 4.6.11 and it does not verify the addresses mail and it does not let continue with the drupal registry, that variable I must change?

I update the module with all the information on the matter and already follows without working.

<?php
// $Id: email_verify.module,v 1.4 2006/01/29 18:34:04 dbr Exp $
// email_verify: Verifies thoroughly that email addresses are correctly entered
//               during registration and account edition
// Copyright: Daniel Bonniot <bonniot@users.sourceforge.net>
// License:   GNU GPL v2 or later
/**
   Display help and module information
   @param section which section of the site we're displaying help
   @return help text for section
*/
function email_verify_help($section = '') {
  $output = '';
  switch ($section) {
    case "admin/modules#description":
      $output = t("Verifies thoroughly email addresses during registration and account edition.");
      break;
  }
  return $output;
}
/**
   Implementation of hook_user().
*/
function email_verify_user($type, &$edit, &$user, $category = NULL) {
  if ($type == 'validate' && $category == 'account') {
    return email_verify_edit_validate(arg(1), $edit);
  }
}
function email_verify_edit_validate($uid, &$edit) {
  // Validate the e-mail address:
  if ($error = email_verify_check($edit['mail'])) {
    form_set_error('mail', $error);
  }
  return $edit;
}
/**
   Verifies whether the given mail address exists.
   @param mail the email address to verify
   @return NULL if the address exists, as far as we could check.
           an error message if we found a problem with the address
*/
function email_verify_check($mail) {
  if (!valid_email_address($mail)) {
    // The address is syntactically incorrect.
    // The problem will be caught by the 'user' module anyway, so we avoid
    // duplicating the error reporting here, just return.
    return;
  }
  $host = substr(strchr($mail, '@'), 1);
  // Let's see if we can find anything about this host in the DNS
  if (function_exists(checkdnsrr) && !checkdnsrr($host, 'ANY')) {
    return t('Email host %host does not seem valid', array('%host' => "$host"));
  }
  // What SMTP servers should we contact?
  $mxHosts = array();
  if (function_exists(getmxrr) && !getmxrr($host, $mxHosts)) {
     // When there is no MX record, the host itself should be used
     $mxHosts[] = $host;
   }
  // Try to connect to one SMTP server
  foreach ($mxHosts as $smtpServer) {
    $connect = @fsockopen($smtpServer, 25, $errno, $errstr, 15);
    if (!$connect) continue;
    if (ereg("^220", $out = fgets($connect, 1024))) {
      // OK, we have a SMTP connection
      break;
    } else {
      // The SMTP server probably does not like us
      // (dynamic/residential IP for aol.com for instance)
      // Be on the safe side and accept the address, at least it has a valid
      // domain part...
      watchdog('email_verify', "Could not verify email address at host $host: $out");
      return;
    }
  }
  if (! $connect)
    return t('Email host %host does not seem valid, it does not answer', array('%host' => "$host"));
  $from = variable_get('site_mail', ini_get('sendmail_from'));
  // Extract the <...> part if there is one
  if (preg_match('/\<(.*)\>/', $from, $match) > 0) {
    $from = $match[1];
  }
  $localhost = $_SERVER["HTTP_HOST"];
  if (!$localhost) // Happens with HTTP/1.0
    //should be good enough for RFC compliant SMTP servers
    $localhost = 'localhost';
  fputs($connect, "HELO $localhost\r\n");
  $out  = fgets($connect, 1024);
  fputs($connect, "MAIL FROM: <$from>\r\n");
  $from = fgets($connect, 1024);
  fputs($connect, "RCPT TO: <{$mail}>\r\n");
  $to   = fgets($connect, 1024);
  fputs($connect, "QUIT\r\n");
  fclose($connect);
  if (!ereg ("^250", $from)) {
    // Again, something went wrong before we could really test the address,
    // be on the safe side and accept it.
    watchdog('email_verify', "Could not verify email address at host $host: $from");
    return;
  }
  if (ereg("(Client host|Helo command) rejected", $to)) {
    // This server does not like us, accept the email address
    // (noos.fr behaves like this for instance)
    watchdog('email_verify', "Could not verify email address at host $host: $to");
    return;
  }
  if (!ereg ("^250", $to )) {
    watchdog('email_verify', "Rejected email address: $mail. Reason: $to");
    return t('Email address %mail does not seem valid', array('%mail' => "$mail"));
  }
  // Everything OK
  return;
}
function email_verify_menu() {
  $items = array();
  $items[] = array('path' => 'email_verify',
   'title' => t('Verify user emails'),
   'callback' => 'email_verify_checkall',
   'access' => user_access('access content'),
   'type' => MENU_CALLBACK);
  return $items;
}
/**
   Look though the whole user base for invalid emails.
   Can be very long when hosts timeout.
*/
function email_verify_checkall() {
  $content = "<table>";
  $found = 0;
  $result = db_query('SELECT uid,name,mail FROM drupal.users');
  while ($row = db_fetch_object($result)) {
    if (email_verify_check($row->mail)) {
      $content .= "<tr><td><a href='?q=user/$row->uid/edit'>$row->name</a><td>$row->mail";
      if(++$found>=100) break;
    }
  }
  $content .= "</table>";
  print theme("page", $content);
}
// Local Variables:
// mode: php
// End:

Version:4.6.x-1.0» master
Status:Needs review» Active

1) my first advice still applies. I recommend Debian Linux: the latest release is very nice.
2) Anyway, there is no patch attached: http://drupal.org/patch
3) Versions for D4.6 and D4.7 are unsupported.

4) There is no need to spam me about this issue by sending me an email via my contact page. I am subscribed to all issues anyway, and I'll help both if I have time and if I am able to.

Title:checkdnsrr and getmxrr error function does not exist module does not verify emailcheckdnsrr and getmxrr error function does not exist
Priority:Critical» Normal

5) Don't combine issues.

Anyway, wouldn't bypassing those two if statements seriously impair the functionality on windows servers?

You can't impair a functionality that doesn't exist.

I'm now trying to upgrade to version 5.2 and I'm getting the following error.
Fatal error: Call to undefined function: getmxrr() in C:\Documents and Settings\My Documents\Web Sites\drupal-5.3\sites\testsite\modules\email_verify\email_verify.install on line 22

I think this is a great idea in the install file but you should also to a function exist here and throw false return to the watchdog. What do you think?

The php.net pages list alternative implementations for windows. What about using them in the module?

http://php.net/checkdnsrr
http://php.net/getmxrr

Yes that's interesting but it relies on the exec() function which also might be disabled on certain hosts.

Guys, would it be possible to put a warning on the project page that this module is not compatible with Windows while a work around is looked at? Has anyone looked at using the Net DNS PEAR package instead which will be platform independent?

http://pear.php.net/package/Net_DNS

Assigned:Unassigned» dbr
Status:Active» Fixed

Apparently the upcoming PHP 5.3 on windows will support the necessary functions.

I applied the patch proposed in http://drupal.org/node/302503 which prints a warning when necessary, but avoids the failure.

Given the situation, I'll mark the issue as fixed (but I would accept a patch to make it work with earlier versions of PHP as well).

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.