Verifying an e-mail address

Verifying an e-mail address

am 27.06.2011 20:53:03 von sono-io

I'd like to find a way to check if an e-mail address that is =
entered on a form is valid or, at the very least, just not invalid. =
Checking CPAN, I ran across a module called Email::Verify::SMTP. Has =
anyone used this before? If so, what are your impressions? =20

If this is not a good module, what would you recommend?

Thanks,
Marc=

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 27.06.2011 21:04:16 von Jim Gibson

On 6/27/11 Mon Jun 27, 2011 11:53 AM, "sono-io@fannullone.us"
scribbled:

> I'd like to find a way to check if an e-mail address that is entered on a form
> is valid or, at the very least, just not invalid. Checking CPAN, I ran across
> a module called Email::Verify::SMTP. Has anyone used this before? If so,
> what are your impressions?
>
> If this is not a good module, what would you recommend?

There is a FAQ entry:

'perldoc -q address' "How do I check a valid mail address?"

that mentions Email::Valid and RFC::RFC822::Address. I haven't used any of
these, so can't recommend any.



--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 27.06.2011 21:05:03 von Octavian Rasnita

From:

I'd like to find a way to check if an e-mail address that is entered on =
a form is valid or, at the very least, just not invalid. Checking CPAN, =
I ran across a module called Email::Verify::SMTP. Has anyone used this =
before? If so, what are your impressions? =20

If this is not a good module, what would you recommend?

Thanks,
Marc


I recommend Email::Valid.

Octavian


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 27.06.2011 21:09:32 von sono-io

Octavian,

> I recommend Email::Valid.

Any particular reason?

Marc

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 27.06.2011 21:14:44 von sono-io

On Jun 27, 2011, at 12:04 PM, Jim Gibson wrote:

> 'perldoc -q address' "How do I check a valid mail address?"

Thanks, Jim, I'm reading that now. However, after glancing at =
it, I may not have been clear in what I actually want. I'm looking to =
see if it's valid as far as preventing an e-mail from bouncing because =
of a non-existant account, bad domain, etc.

Marc=

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

RE: Verifying an e-mail address

am 27.06.2011 21:20:42 von David.Wagner

>-----Original Message-----
>From: sono-io@fannullone.us [mailto:sono-io@fannullone.us]
>Sent: Monday, June 27, 2011 13:15
>To: Jim Gibson
>Cc: Perl Beginners
>Subject: Re: Verifying an e-mail address
>
>On Jun 27, 2011, at 12:04 PM, Jim Gibson wrote:
>
>> 'perldoc -q address' "How do I check a valid mail address?"
>
> Thanks, Jim, I'm reading that now. However, after glancing at it, I
>may not have been clear in what I actually want. I'm looking to see if
>it's valid as far as preventing an e-mail from bouncing because of a =
non-
>existant account, bad domain, etc.
>
>Marc
>--
Unless you make it a two step process: 1) Send email and individual has =
to reply or click an url, I don't believe you can know if the account is =
active, etc WITOUT the sending. Someone may have different view and =
ability, but I can provide you a very valid looking email, but unless =
sent, you will never know..

         If you have any questions and/or problems, =
please let me know.=20
        =A0Thanks.=20
=A0
Wags ;)=20
David R. Wagner=20
Senior Programmer Analyst=20
FedEx Services=20
1.719.484.2097 Tel=20
1.719.484.2419 Fax=20
1.408.623.5963 Cell
http://Fedex.com/us
=09
>To unsubscribe, e-mail: beginners-unsubscribe@perl.org
>For additional commands, e-mail: beginners-help@perl.org
>http://learn.perl.org/
>


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 27.06.2011 21:22:48 von Jim Gibson

On 6/27/11 Mon Jun 27, 2011 12:14 PM, "sono-io@fannullone.us"
scribbled:

> On Jun 27, 2011, at 12:04 PM, Jim Gibson wrote:
>
>> 'perldoc -q address' "How do I check a valid mail address?"
>
> Thanks, Jim, I'm reading that now. However, after glancing at it, I may not
> have been clear in what I actually want. I'm looking to see if it's valid as
> far as preventing an e-mail from bouncing because of a non-existant account,
> bad domain, etc.

Yes. That is the problem addressed by the FAQ:

"How do I check a valid mail address?
(partly contributed by Aaron Sherman)

This isn't as simple a question as it sounds. There are two parts:

a) How do I verify that an email address is correctly formatted?

b) How do I verify that an email address targets a valid recipient?

Without sending mail to the address and seeing whether there's a human
on the other end to answer you, you cannot fully answer part b, but
either the "Email::Valid" or the "RFC::RFC822::Address" module will do
both part a and part b as far as you can in real-time."





--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 27.06.2011 22:04:50 von sono-io

On Jun 27, 2011, at 12:20 PM, Wagner, David wrote:

> Unless you make it a two step process: 1) Send email and =
individual has to reply or click an url, I don't believe you can know if =
the account is active, etc WITOUT the sending.=20

I can see how that would work fine for a forum, but this will be =
for a shopping cart. I know that there isn't a perfect solution - all I =
want would be to try to prevent someone from entering a blatantly wrong =
address. The other day, I had someone enter an address like =
sally123@yahoo.com. This morning, when I e-mailed her directly, it =
bounced back immediately as user unknown which means she didn't get her =
e-mail from the cart and I wasn't aware of that until now.

It seems that all I'd need would be to check 1) if the domain is =
good and 2) whether or not the user has an account on that domain.

I'll be checking out Email::Valid and Email::Verify::SMTP to see =
if either of these might prevent that type of scenario from happening =
again.

Thanks again,
Marc


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 27.06.2011 22:17:34 von Octavian Rasnita

From:
On Jun 27, 2011, at 12:20 PM, Wagner, David wrote:

> Unless you make it a two step process: 1) Send email and individual =
has to reply or click an url, I don't believe you can know if the =
account is active, etc WITOUT the sending.=20

I can see how that would work fine for a forum, but this will be for a =
shopping cart. I know that there isn't a perfect solution - all I want =
would be to try to prevent someone from entering a blatantly wrong =
address. The other day, I had someone enter an address like =
sally123@yahoo.com. This morning, when I e-mailed her directly, it =
bounced back immediately as user unknown which means she didn't get her =
e-mail from the cart and I wasn't aware of that until now.

It seems that all I'd need would be to check 1) if the domain is good =
and 2) whether or not the user has an account on that domain.

I'll be checking out Email::Valid and Email::Verify::SMTP to see if =
either of these might prevent that type of scenario from happening =
again.

Thanks again,
Marc



If you don't controll the domains, you won't be able to find if the =
email addresses really exist without sending the email.

Octavian



--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 27.06.2011 22:22:06 von Rob Dixon

On 27/06/2011 19:53, sono-io@fannullone.us wrote:
>
> I'd like to find a way to check if an e-mail address that is entered
> on a form is valid or, at the very least, just not invalid. Checking
> CPAN, I ran across a module called Email::Verify::SMTP. Has anyone
> used this before? If so, what are your impressions?
>
> If this is not a good module, what would you recommend?

Hi Marc.

For doing the job of validating the format of an email address I suggest
Regexp::Common. Take a look at the code below.

Verifying that the address is a correct an functional is another matter
altogether, and a problem that I believe cannot be solved in general, if
for no other reason than that it would be a God-send for spammers.

Cheers,

Rob


use strict;
use warnings;

use Regexp::Common 'Email::Address';

my $email_re = $RE{Email}{Address};

print 'OK' if 'sono-io@fannullone.us' =~ $email_re;

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

RE: Verifying an e-mail address

am 27.06.2011 22:27:22 von Bob McConnell

From: sono-io@fannullone.us

> On Jun 27, 2011, at 12:20 PM, Wagner, David wrote:
>=20
> > Unless you make it a two step process: 1) Send email and
individual has to reply or click an url, I don't believe you can know if
the account is active, etc WITOUT the sending.=20
>=20
> I can see how that would work fine for a forum, but this will be
for a shopping cart. I know that there isn't a perfect solution - all I
want would be to try to prevent someone from entering a blatantly wrong
address. The other day, I had someone enter an address like
sally123@yahoo.com. This morning, when I e-mailed her directly, it
bounced back immediately as user unknown which means she didn't get her
e-mail from the cart and I wasn't aware of that until now.
>=20
> It seems that all I'd need would be to check 1) if the domain is
good and 2) whether or not the user has an account on that domain.
>=20
> I'll be checking out Email::Valid and Email::Verify::SMTP to see
if either of these might prevent that type of scenario from happening
again.

The problem with this is that, due to the spam plague, most servers will
no longer tell you if an address is valid. Many do not even return a
bounce message, but silently discard any and all mail for unknown
addresses. Spam traps can also produce false positives, dumping your
mail into a quarantine folder, or the bit bucket. The only time you know
an address is valid is if you receive an actual response from the user.
Even then I would be worried that it could be a 'bot responding to you.

Email should no longer be considered a reliable basis to make financial
decisions.

Bob McConnell

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 27.06.2011 22:46:26 von sono-io

On Jun 27, 2011, at 1:27 PM, Bob McConnell wrote:

> The problem with this is that, due to the spam plague, most servers =
will
> no longer tell you if an address is valid. Many do not even return a
> bounce message, but silently discard any and all mail for unknown
> addresses.

Good points. I'm so used to Perl doing what I tell it to do =
that I wasn't thinking about that. =3D;) So what about just checking =
the MX record for a domain? Let's say someone entered xxx@yagoo.com =
instead of xxx@yahoo.com. Is that catchable or would there be problems =
with that as well?

Marc=

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 28.06.2011 07:28:00 von Octavian Rasnita

From:
On Jun 27, 2011, at 1:27 PM, Bob McConnell wrote:

> The problem with this is that, due to the spam plague, most servers will
> no longer tell you if an address is valid. Many do not even return a
> bounce message, but silently discard any and all mail for unknown
> addresses.

Good points. I'm so used to Perl doing what I tell it to do that I wasn't
thinking about that. =;) So what about just checking the MX record for a
domain? Let's say someone entered xxx@yagoo.com instead of xxx@yahoo.com.
Is that catchable or would there be problems with that as well?

Marc
--


It is the same. The program may think that the host yagoo.com is a valid
host and that email address is a valid one.

You may verify if a certain host can be found, but if you won't find it, it
doesn't mean that it really doesn't exist, because it may be down
temporarily or for other reasons...

Octavian


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 01.07.2011 17:25:44 von sono-io

Rick,

Thank's for the script! I appreciate your help.

Marc



On Jun 27, 2011, at 5:24 PM, Rick Sanders wrote:

> Hi,
>=20
> I posted a reply to your question but it hasn't shown up yet so maybe =
there's a problem with my News server. Anyway, here is a script that =
should let you do verify e-mail addresses.
>=20
> If my reply doesn't make it to the the newsgroup you can post this if =
you like.
>=20
> -Rick
>=20
> -------- Original Message --------
>=20
> Keep in mind all of the warnings mentioned in this thread. This is a
> simple script that tries to validate a mail address.
>=20
> It queries DNS for the MX record for the user's domain followed by an
> SMTP connection to one of the domain's MX servers. After sending =
"HELO"
> and "MAIL FROM" commands it issues a "RCPT TO" command, and then sends
> "QUIT" (eg, it doesn't actually send a message).
>=20
> Typical responses:
>=20
> 250 2.1.5 OK z9si15926030ibd.51
> 250 ... Recipient Ok
> 550 gfs@earthlink.net...User unknown
> 550-5.1.1 The email account that you tried to reach does not exist
>=20
> Warning: This is just a demo script. It has no error checking, retry
> capability, or the ability to try multiple MX servers. It doesn't even
> try to check whether the address is constructed correctly.
>=20
> -Rick
>=20
> #!/usr/bin/perl
>=20
> use strict;
> use Net::DNS;
> use Socket;
> my @mx_hosts;
> my $recipient;
>=20
> # Determine if an e-mail address is valid.
> # Look up in DNS the MX server that handles mail for the
> # recipient's domain and ask it if the address is valid.
>=20
> if ( @ARGV[0] ) {
> $recipient =3D $ARGV[0];
> } else {
> print "Usage: ./verify_mail_address.pl \n\n";
> exit;
> }
>=20
> my ($userid,$domain) =3D split( /\@/, $recipient );
>=20
> print "\nChecking $recipient\n\n";
>=20
> my $res =3D Net::DNS::Resolver->new;
> my @mx =3D mx( $res, $domain );
> foreach my $rr ( @mx ) {
> my $pref =3D $rr->preference;
> my $mx_host =3D $rr->exchange;
> push( @mx_hosts, $mx_host );
> }
>=20
> # If any of the mx hosts don't answer you can try another one.
> # You may want to sort by the rr->preference value but for this
> # example we'll just grab the first one from the list
>=20
> my $mx_host =3D pop( @mx_hosts );
>=20
> my $status =3D check_recipient( $recipient, $mx_host );
>=20
> print "$status\n";
> exit;
>=20
>=20
>=20
> sub check_recipient {
>=20
> my $recipient =3D shift;
> my $smtp_server =3D shift;
> my $my_domain =3D 'mydomain.com';
> my $my_address =3D 'me@mydomain.com';
> my $recip_status;
>=20
> # Open a connection to an MX host on the SMTP port and
> # ask if a recipient is a valid user in its domain.
>=20
> my $proto =3D getprotobyname('tcp');
> socket(SERVER, AF_INET, SOCK_STREAM, $proto);
> my $iaddr =3D gethostbyname($smtp_server);
> my $port =3D getservbyname('smtp', 'tcp');
>=20
> my $sin =3D sockaddr_in($port, $iaddr);
>=20
> my $sreply;
>=20
> connect(SERVER, $sin);
> recv SERVER, $sreply, 512, 0;
>=20
> send SERVER, "HELO $my_domain\r\n", 0;
> recv SERVER, $sreply, 512, 0;
>=20
> send SERVER, "MAIL From:<$my_address>\r\n", 0;
> recv SERVER, $sreply, 512, 0;
>=20
> send SERVER, "RCPT To:<$recipient>\r\n", 0;
> recv SERVER, $recip_status, 512, 0;
>=20
> send SERVER, "QUIT\r\n", 0;
> recv SERVER, $sreply, 512, 0;
>=20
> close SERVER;
>=20
> return $recip_status;
>=20
> }


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 01.07.2011 17:50:16 von Wernher Eksteen

--000e0cd5d2625a7d3c04a703f93d
Content-Type: text/plain; charset=ISO-8859-1

On 27 June 2011 20:53, wrote:

> I'd like to find a way to check if an e-mail address that is entered
> on a form is valid or, at the very least, just not invalid. Checking CPAN,
> I ran across a module called Email::Verify::SMTP. Has anyone used this
> before? If so, what are your impressions?
>
> If this is not a good module, what would you recommend?
>
> Thanks,
> Marc
>

Hi,

Also have a look at this module if SPF is involved: Mail::SPF::Query

-Wernher

--000e0cd5d2625a7d3c04a703f93d--

RE: Verifying an e-mail address

am 05.07.2011 12:51:18 von Mimi Cafe

I have used Email::Valid and it's simple to use as in example below:

use Email::Valid;

sub email_validation {

my $email = shift;


# return true if email address is valid.
return(Email::Valid->address( -address => "$email", -mxcheck => 1 ) ?
'1' : '0');


}

=> -----Original Message-----
=> From: Jim Gibson [mailto:jimsgibson@gmail.com]
=> Sent: 27 June 2011 20:04
=> To: Perl Beginners
=> Subject: Re: Verifying an e-mail address
=>
=> On 6/27/11 Mon Jun 27, 2011 11:53 AM, "sono-io@fannullone.us"
=> scribbled:
=>
=> > I'd like to find a way to check if an e-mail address that is entered
=> on a form
=> > is valid or, at the very least, just not invalid. Checking CPAN, I
=> ran across
=> > a module called Email::Verify::SMTP. Has anyone used this before?
=> If so,
=> > what are your impressions?
=> >
=> > If this is not a good module, what would you recommend?
=>
=> There is a FAQ entry:
=>
=> 'perldoc -q address' "How do I check a valid mail address?"
=>
=> that mentions Email::Valid and RFC::RFC822::Address. I haven't used
=> any of
=> these, so can't recommend any.
=>
=>
=>
=> --
=> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
=> For additional commands, e-mail: beginners-help@perl.org
=> http://learn.perl.org/
=>



--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Verifying an e-mail address

am 05.07.2011 13:44:05 von Rob Dixon

On 27/06/2011 21:46, Marc wrote:
> On Jun 27, 2011, at 1:27 PM, Bob McConnell wrote:
>
>> The problem with this is that, due to the spam plague, most servers will
>> no longer tell you if an address is valid. Many do not even return a
>> bounce message, but silently discard any and all mail for unknown
>> addresses.
>
> Good points. I'm so used to Perl doing what I tell it to do that I
> wasn't thinking about that. =;) So what about just checking the MX
> record for a domain? Let's say someone entered xxx@yagoo.com instead of
> xxx@yahoo.com. Is that catchable or would there be problems with that as
> well?

If this is for an internet shopping cart, then don't forget that, as
well as checking that an entered email address has a valid syntax and is
a real and active email account, you need to check for fraudulent entries.

Even if an email address is valid and real, there is nothing to stop
someone creating an account or placing an order with someone else's
address. That is why all internet ordering systems send a confirmation
request to the address, which must be responded to to establish that the
the request was genuine.

Since a confirmation email also tests that the address is valid and
real, no other test is required (although it would make sense to ensure
that the address at least /looked/ like a valid email before using it to
send a confirmation request).

HTH,

Rob

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/