checking if mail address is valid 
Author Message
 checking if mail address is valid

i am trying to check if a mail address is valid from perl. I do this
by checking if www.<server> or smtp.<server> exists (resolve ip). This
seems to work in 99% of all cases, but not all. Anybody know a more
reliable way?

greetings,
Sander



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid

Quote:

> i am trying to check if a mail address is valid from perl. I do this by
> checking if www.<server> or smtp.<server> exists (resolve ip). This
> seems to work in 99% of all cases, but not all. Anybody know a more
> reliable way?

> greetings, Sander

You can as ways look up the MX record(s) for the domain given in the
email address.


-Josh



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid

Quote:
>> On Thu, 30 Nov 2000 21:57:53 -0500,



>> i am trying to check if a mail address is valid from
>> perl. I do this by checking if www.<server> or
>> smtp.<server> exists (resolve ip). This seems to work
>> in 99% of all cases, but not all. Anybody know a more
>> reliable way?

>> greetings, Sander
> You can as ways look up the MX record(s) for the domain
> given in the email address.


Sadly that's fairly pointless:

    perldoc -q 'mail address'  ==>  perlfaq9

       How do I check a valid mail address?

       You can't, at least, not in real time.  Bummer, eh?

hth
t
--
Eih bennek, eih blavek.



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid



Quote:
> i am trying to check if a mail address is valid from perl. I do this
> by checking if www.<server> or smtp.<server> exists (resolve ip). This
> seems to work in 99% of all cases, but not all. Anybody know a more
> reliable way?

> greetings,
> Sander

i would recommend to use regular expressions

greetinx

Sebastian
PS: if you have further questions you can reach me via ICQ 99091607



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid



Quote:



> > i am trying to check if a mail address is valid from perl. I do this
> > by checking if www.<server> or smtp.<server> exists (resolve ip). This
> > seems to work in 99% of all cases, but not all. Anybody know a more
> > reliable way?

> > greetings,
> > Sander

> i would recommend to use regular expressions

> greetinx

> Sebastian
> PS: if you have further questions you can reach me via ICQ 99091607

sorry, mailprog crashed, here comes part 2:
first use regex to validate format of mail address and then try to resolve
via
DNS.


Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid

Quote:
>Sadly that's fairly pointless:

>    perldoc -q 'mail address'  ==>  perlfaq9

>       How do I check a valid mail address?

>       You can't, at least, not in real time.  Bummer, eh?

>hth
>t

This may seem like a naive remark, but mail servers do it don't they?
I mean a mail server should connect to some foreign address before
sending the mail to it. Failing to connect should be a reliable
indication that the address is invalid (in which case the mail is
bounched to the sender).

greetings,
Sander

PS: the routine i use DOES work. It just isnt perfect.



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid

Quote:

>sorry, mailprog crashed, here comes part 2:
>first use regex to validate format of mail address and then try to resolve
>via
>DNS.

My routine already checks the syntax of the address, so this doesnt
pose a problem. How do I resolve the addresss via DNS? Example:

xxx.finnforest.nl exists.


Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid

Quote:
>> On Thu, 30 Nov 2000 14:58:53 GMT,

> This may seem like a naive remark, but mail servers do
> it don't they?  I mean a mail server should connect to
> some foreign address before sending the mail to
> it. Failing to connect should be a reliable indication
> that the address is invalid (in which case the mail is
> bounched to the sender).

Mail servers work out where they're going to send the mail
but the question of whether the recipient is valid cannot
be addressed.  The mail (smtp) server sends to a remote
site usually through MX lookups but it is the remote
site's smtp daemon which either accepts or rejects the
transaction.  Further configuration at the remote site may
then cause the email to be sent elsewhere (e.g. .forward
file), which makes a validation process even more
impossible ("more impossible"?  I think I need coffee).

Quote:
> PS: the routine i use DOES work. It just isnt perfect.

I guess that depends on what you consider "working" :-)

This is now getting way off-topic for clp.misc.

hth
t
--
Eih bennek, eih blavek.



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid

Quote:


>>Sadly that's fairly pointless:

>>    perldoc -q 'mail address'  ==>  perlfaq9

>>       How do I check a valid mail address?

>>       You can't, at least, not in real time.  Bummer, eh?

>>hth t

> This may seem like a naive remark, but mail servers do it don't they? I
> mean a mail server should connect to some foreign address before sending
> the mail to it. Failing to connect should be a reliable indication that
> the address is invalid (in which case the mail is bounched to the
> sender).

> greetings, Sander

> PS: the routine i use DOES work. It just isnt perfect.

You can go a step further to:

#!/usr/bin/perl -w  

use strict;
use Net::DNS;
use Net::SMTP;





 my $smtp = Net::SMTP->new($rr->exchange);



 } else {
   print "Invalid address: Mail host will not except mail.\n";
 }

Quote:
} else {

 print "Invalid address: No mail server found.\n";

- Show quoted text -

Quote:
}



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid
Sebastian Meyer wrote in comp.lang.perl.misc:

Quote:

> > > i am trying to check if a mail address is valid from perl. I do this
> > > by checking if www.<server> or smtp.<server> exists (resolve ip). This
> > > seems to work in 99% of all cases, but not all. Anybody know a more
> > > reliable way?

> > i would recommend to use regular expressions

A regular expression is not sufficient to parse all RFC 822 compliant
mail addresses. You want to use the Mail::Address module, available on
CPAN. It can reliably extract the host part of the mail address.

--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid

Quote:

>You can go a step further to:

>#!/usr/bin/perl -w  

>use strict;
>use Net::DNS;
>use Net::SMTP;





> my $smtp = Net::SMTP->new($rr->exchange);



> } else {
>   print "Invalid address: Mail host will not except mail.\n";
> }
>} else {
> print "Invalid address: No mail server found.\n";
>}

This all looks wonderful, but when I upload a script trying to test

we have ActivePerl, but it doesnt have Net::DNS either). Nor can I
find anything on this package in 'Perl in a Nutshell'.  :-(

I would like to thank all for you thoughts on this problem, like Tony
said, this is getting off topic. (any new ideas are appreciated
though).

greetings,
Sander



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid

Quote:

>This all looks wonderful, but when I upload a script trying to test

>we have ActivePerl, but it doesnt have Net::DNS either). Nor can I
>find anything on this package in 'Perl in a Nutshell'.  :-(

It isn't installed, then. You can get it from CPAN:
<http://search.cpan.org/search?dist=Net-DNS>

--
        Bart.



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid

Quote:

>It isn't installed, then. You can get it from CPAN:
><http://search.cpan.org/search?dist=Net-DNS>

Yeah, i thought of that myself of course. This probably would work on
our intranet, but we don't host the scripts. Our provider does, and I
don't think I am allowed to install packages. I have to work with
what's available.

greetings,
Sander



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid

Quote:

>>It isn't installed, then. You can get it from CPAN:
>><http://search.cpan.org/search?dist=Net-DNS>

>Yeah, i thought of that myself of course. This probably would work on
>our intranet, but we don't host the scripts. Our provider does, and I
>don't think I am allowed to install packages. I have to work with
>what's available.

It doesn't require installation, AFAI can tell. It looks like it's all
plain Perl code. It could be that all you need to do is decompress the
archive, get the proper subtree, and put it in a custom directory for
libraries. Then, all you need to do is

        use lib '/my/custim/lib/path';

at the top of your script.

See also, the FAQ, perlfaq8:

  How do I keep my own module/library directory?

--
        Bart.



Wed, 18 Jun 1902 08:00:00 GMT  
 checking if mail address is valid
Is it just me or since the "FAQ server" autoposts started up again has
the number of people posting questions that are almost verbatim out
the the FAQ actually increased?


Quote:
> i am trying to check if a mail address is valid from perl.

See FAQ: "How do I check a valid mail address?"

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 19 post ]  Go to page: [1] [2]

 Relevant Pages 

1. check for valid e-mail address

2. Checking for a valid e-mail address

3. Regexp to check for valid e-mail address?

4. ??Check Valid E-mail Address??

5. How to check if an email address is valid

6. Quickie: regexp for valid e-mail addresses

7. parsing input to confirm a valid e-mail address

8. Finding if an E-Mail address is valid??

9. Help! Checking e-mail address format

10. Quick and Dirty e-mail address check?

11. FAQ 9.17 How do I check a valid mail address?

12. FAQ 9.17 How do I check a valid mail address?

 

 
Powered by phpBB® Forum Software