Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

MX Lookups

by Anonymous Monk
on Jun 10, 2002 at 15:38 UTC ( [id://173274]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm a little stuck, just how do you lookup MX records using perl? Plain DNS lookups are no problem, but I need something to do dig style lookups..... I'm missing something obvious I know :) Any examples would be very greatfully recived. TIA.

Replies are listed 'Best First'.
Re: MX Lookups
by neilwatson (Priest) on Jun 10, 2002 at 15:59 UTC
Re: MX Lookups
by grinder (Bishop) on Jun 10, 2002 at 16:31 UTC
    If you have Net::DNS lying around this is a snap to write:

    #! /usr/local/bin/perl -w use strict; use Net::DNS; my $dns = new Net::DNS::Resolver; for my $domain( @ARGV ) { my $mx = $dns->query( $domain, 'MX' ); print "$domain\n"; foreach my $rr ($mx->answer) { print "\t", $rr->exchange, ' (', $rr->preference, ")\n"; } } __END__ output: % ./mx perl.org perlmonk.org perlmonks.org perl.com perl.org lux.valueclick.com (20) perlmail.valueclick.com (10) perlmonk.org perlmonk.org (10) perlmonks.org mail.egl.net (5) perl.com mail.perl.com (0)


    print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'
Re: MX Lookups
by hakkr (Chaplain) on Jun 11, 2002 at 08:37 UTC
    Cpan module Email::Valid does an Mx lookup and syntax check

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://173274]
Approved by mdillon
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.