Perl-Email-Project / Email-Valid

perl library to validate email addresses
19 stars 19 forks source link

mxcheck passes for domains that do not have MX records #17

Closed tmorehouse closed 8 years ago

tmorehouse commented 9 years ago

It appears that some domains that do not have MX records pass the Net::DNS mx check routine (I haven't checked if the same issue occurs with the nslookup routine).

The following change makes the Net::DNS MX record check fail correctly for these domains:

sub _net_dns_query {
  my $self = shift;
  my $host = shift;

  $Resolver = Net::DNS::Resolver->new unless defined $Resolver;

  my @mx_entries = Net::DNS::mx($Resolver,$host);

  if (@mx_entries) {
    foreach my $mx (@mx_entries) {
      my $mxhost = $mx->exchange;
      my $query = $Resolver->search($mxhost);
      foreach my $a_rr ($query->answer) {
        return 1 unless $a_rr->type ne 'A';
      }
    }
  }

  return $self->details('mx');
}
tmorehouse commented 9 years ago

PR #18 contains this fix.

rjbs commented 8 years ago

18 was merged

tmorehouse commented 8 years ago

Excellent :)