in reply to gethostbyname() and www prefix
Update: If we don't find an MX record, we now check to see if that address exists using gethostbyname(), as it's valid to have hosts without MX records. Thanks to Kanji for spotting this.use Net::DNS; my $resolver = Net::DNS::Resolver->new; my $domain = "perlmonks.org"; my $query = $resolver->query($domain,"MX"); if ($query) { # They have an MX record, send the mail. } elsif (gethostbyname($domain)) { # No MX record, but the host exists. Send the # mail. } else { # No host, and no MX. No mail for you! }
Cheers,
Paul
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: gethostbyname() and www prefix
by tachyon (Chancellor) on Oct 08, 2001 at 13:35 UTC |