Skip to content

Instantly share code, notes, and snippets.

@tateisu
Created May 22, 2018 17:24
Show Gist options
  • Save tateisu/7158814ca15700808364e3b83f35d47a to your computer and use it in GitHub Desktop.
Save tateisu/7158814ca15700808364e3b83f35d47a to your computer and use it in GitHub Desktop.
#!perl --
## $ perl check-email-mx.pl <email.txt
use strict;
use warnings;
use Net::DNS;
my %mx;
for(;;){
my $email = <>;
last if not $email;
$email =~ s/[\x0d\x0a]+//;
next if not $email =~ /(.+?)\@(.+)/;
my($user,$domain)=($1,$2);
my $mx_list = $mx{$domain};
if(not $mx_list){
my @names = map{ $_->exchange } mx($domain);
$mx_list = $mx{$domain} = \@names;
}
for my $mx (@$mx_list){
if( $mx =~ /\Q.mailasrvs.pw\E/ ){
print "$email: $mx\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment