diff -urp email_verify_orig/email_verify.inc.php email_verify/email_verify.inc.php --- email_verify_orig/email_verify.inc.php 2009-04-11 13:07:12.000000000 +0200 +++ email_verify/email_verify.inc.php 2011-02-16 17:39:34.924195001 +0100 @@ -21,6 +21,11 @@ function _email_verify_check($mail) { $host = substr(strchr($mail, '@'), 1); + // check if the email domain is not in blacklist + if (_email_domain_inblacklist($host)) { + return t('Email host %host is not permitted, please retry.', array('%host' => "$host")); + } + // Let's see if we can find anything about this host in the DNS if (!checkdnsrr($host, 'ANY')) { return t('Email host %host invalid, please retry.', array('%host' => "$host")); @@ -108,3 +113,58 @@ function _email_verify_check($mail) { // Everything OK return; } + +function email_verify_blacklist() { + $form = array(); + + $_blacklist = variable_get('hosts_blacklist',"gmail.com\nyahoo.com"); + if(is_array($_blacklist)) { + $blacklist = implode("\n",$_blacklist); + } else { + $blacklist = $_blacklist; + } + + $form['hosts_blacklist'] = array( + '#title' => t('Blacklisted Hosts'), + '#type' => 'textarea', + '#required' => FALSE, + '#default_value' => $blacklist, + '#description' => t('Insert list of dns to blacklist'), + ); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit') + ); + return $form; +} + +function email_verify_blacklist_submit($form, &$form_state) { + + $blacklist = explode("\n",trim($form_state['values']['hosts_blacklist'])); + + foreach ($blacklist as $key => $value) { + if (is_null($value) || trim($value)=="" || !eregi("^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", trim($value))) { + unset($blacklist[$key]); + } + } + + variable_set('hosts_blacklist', $blacklist); + + drupal_set_message(t('Blacklist saved.')); +} + +function _email_domain_inblacklist($host) { + + //blacklist array within not allowed dns + $blacklist = variable_get('hosts_blacklist',""); + if (is_array($blacklist)) { + foreach ($blacklist as $key => $value) { + if (trim($value) == $host) { + return true; + } + } + } else { + return false; + } +} diff -urp email_verify_orig/email_verify.module email_verify/email_verify.module --- email_verify_orig/email_verify.module 2009-04-11 12:41:10.000000000 +0200 +++ email_verify/email_verify.module 2011-02-16 17:25:42.534195001 +0100 @@ -59,6 +59,15 @@ function email_verify_menu() { 'type' => MENU_LOCAL_TASK, 'file' => 'email_verify.check.inc', ); + $items['admin/user/user/blacklist'] = array( + 'title' => 'Add a host in blacklist', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('email_verify_blacklist'), + 'access arguments' => array('administer users'), + 'type' => MENU_LOCAL_TASK, + 'file' => 'email_verify.inc.php', + ); + return $items; }