#!/usr/bin/perl -w use strict; use Net::DNS; my $domain_file = $ARGV[0]; die "usage: $0 domainfile" unless( $domain_file and -e $domain_file ); my $resolver = new Net::DNS::Resolver; open my $fh, '<', $domain_file or die $!; while( my $domain = <$fh> ){ chomp $domain; # MX-Record abfragen my @mxrecs = mx($resolver, $domain); if (@mxrecs){ # Gefunden! foreach my $rec (@mxrecs){ print $rec->preference, " ", $rec->exchange, "\n"; } } else{ # Leere Liste, Fehler! print "Kein MX-Record für $domain: ", $resolver->errorstring, "\n"; } }