--- /home/dm_50/sites/all/modules/email/email.module 2008-04-15 07:56:09.000000000 -0400 +++ ./email.module 2008-11-05 13:26:34.000000000 -0500 @@ -113,6 +113,13 @@ '#required' => FALSE, '#description' => t('Size of textfield'), ); + $form['extra_validation'] = array( + '#type' => 'checkbox', + '#title' => t('Extended validation?'), + '#default_value' => isset($widget['extra_validation']) ? $widget['extra_validation'] : 0, + '#required' => FALSE, + '#description' => t('Apply more stringent tests to the email address (requires a FQDN that actually exists).'), + ); return $form; @@ -123,7 +130,7 @@ break; case 'save': - return array('size'); + return array('size','extra_validation'); } } @@ -182,6 +189,15 @@ foreach ($node_field as $delta => $item) { if ($item['email'] != '' && !valid_email_address(trim($item['email']))) { form_set_error($field['field_name'],t('"%mail" is not a valid email address',array('%mail' => $item['email']))); + $item['email'] = ''; + } + + if ($field['widget']['extra_validation'] && $item['email'] != '') { + $FQDN = '/^(?:[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])+(?:\.(?:[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])+)*(?:\.[a-zA-Z]{2,})$/'; + list($mailbox,$domain) = split('@', trim($item['email'])); + if(!preg_match($FQDN, $domain) || !checkdnsrr($domain .'.', 'MX')) { + form_set_error($field['field_name'],t('"%mail" does not contain a valid domain',array('%mail' => $item['email']))); + } } } }