This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Checking email against DNS MX record


  1. vern1271
    Member

    I'm trying to add DNS MX validation and I must be missing something, because I can't get it to work...

    In the common-validator.php file after line 28, I added the following...

    //validate DNS MX record
    function domain_exists($value) {

    list($user,$domain) = split('@',$value);

    if (!checkdnsrr($domain,'MX')) {
    return 'Sorry, This domain is not valid';
    } else {
    return true;
    }

    }

    And in my post-functions.php file I added the following after $rules[$element_name]['email'] = true; on line 296 since I only want to do this on certain forms:

    if ($form_id == '3') {
    $rules[$element_name]['domain_exists'] = true;
    }

    Any help would be appreciated.

    Posted 14 years ago #
  2. yuniar

    Try changing your function to become like this:

    function domain_exists($value) {
    
    $value = $value[0];
    list($user,$domain) = split('@',$value);
    
    if (!checkdnsrr($domain,'MX')) {
       return 'Sorry, This domain is not valid';
    } else {
       return true;
    }
    
    }

    `


    MachForm Founder

    Posted 14 years ago #
  3. vern1271
    Member

    No luck... Anyone else ever implement this and get it working?

    Posted 14 years ago #
  4. yuniar

    Hmm.. have you checked if the function checkdnsrr($domain,'MX') already worked fine on your site?

    If you are using Windows server, this function only available since PHP 5.3.0


    MachForm Founder

    Posted 14 years ago #

RSS feed for this topic

Reply