At the risk of repeating oft-given advice, why don't you have a look at Email::Valid? - This module provides a means of performing email address validation and includes the option of performing domain mail exchanger checks on email addresses submitted for validation.

The Examples section of POD documentation for this module even includes some notes on DNS checks on email addresses.

From this POD ...

 

Examples

Let's see if the address 'maurice@hevanet.com' conforms to the RFC822 specification:

print (Email::Valid->address('maurice@hevanet.com') ? 'yes' : 'no');

Additionally, let's make sure there's a mail host for it:

print (Email::Valid->address( -address => 'maurice@hevanet.com', -mxcheck => 1 ) ? 'yes' : 'no');

Let's see an example of how the address may be modified:

$addr = Email::Valid->address('Alfred Neuman <Neuman @ foo.bar>'); print "$addr\n"; # prints Neuman@foo.bar

Need to determine why an address failed?

unless(Email::Valid->address('maurice@hevanet')) { print "address failed $Email::Valid::Details check.\n"; }

If an error is encountered, an exception is raised. This is really only possible when performing DNS queries. Trap any exceptions by wrapping the call in an eval block:

eval { $addr = Email::Valid->address( -address => 'maurice@hevanet.com', -mxcheck => 1 ); }; warn "an error was encountered: $@" if $@;

 

Ooohhh, Rob no beer function well without!


In reply to Re: gethostbyname() and www prefix by rob_au
in thread gethostbyname() and www prefix by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.