0

Hello,

I am after some help,

I need to know how to do srv lookups using php and possibly mx lookup,

I have a form which already has a textbox which selects the domian from a mysql database, I need to be able to display the srv record below the textbox, the srv record needs to start with _autodiscover._tcp.

I have looked online and you can use dns_get_record but can't seem to get in working for srv lookups

Can Anyone help

Cheers
Martin

2
Contributors
4
Replies
34
Views
3 Years
Discussion Span
Last Post by urbanthistleuk
1

You could use getmxrr():

<?php

    $url = 'daniweb.com';
    getmxrr($url, $matches, $weights);

    print_r($matches);
    print_r($weights);

Docs: http://php.net/getmxrr

Regarding dns_get_record() what kind of problem do you experience? Can you show your script?

I need to be able to display the srv record below the textbox, the srv record needs to start with _autodiscover._tcp.

Do you mean you want to filter and get only those with _autodiscover._tcp.? Here you can use strstr() or preg_match() or even preg_match_all() if the record contains more then one matching string.

0

Hi Cereal,

The code I am using is

<?php
$domain = strstr('_autodiscover._tcp.');

$result = dns_get_record("domain.com", DNS_SRV, $domain);
print_r($result);
?>

Thanks

Edited by urbanthistleuk

0

Then you need something like this:

<?php

$url = 'domain.com';

$dnsquery = dns_get_record($url, DNS_SRV);
$records = array();
$match = '_autodiscover._tcp';

foreach($dnsquery as $key => $entry)
{
    if(strstr($entry['target'], $match) !== FALSE)
    {
        $records[] = $entry;
    }
}

print_r($records);

The $records variable will return an array of entries that match the string. If it does not work try with DNS_ALL.

0

Thanks,

Can't get it to work, just get an output of array() have tried both dns_all and dns_srv, gives me somthing to work on though

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.