A very common fallacy is that the local-part ( the part to the left of the @)
has a limited character set. I'm pretty amazed at how far that misinformation
has seem to spread. My friend Eli, with a perfectly legal email address
of <*@qz.to> would clearly object to you not seeing his address.
And <fred&barney@stonehenge.com> is a perfectly legal email
address: try sending a message to it!
The proper answer is not to try to match the local-part with a small regex,
but instead to use modules like Email::Valid and RFC::RFC822::Address which actually look at
the specs instead of propogating a myth based on only what you've seen
on your limited exposure to the net.
-- Randal L. Schwartz, Perl hacker | [reply] [d/l] [select] |
Thank you Randal
I tend to avoid solutions based on multiple modules if possible, and in my limited exposure to the net I have found that simple, generalized, solutions based on real
world situations tend to work very nicely, especially if you mark the pieces that do not conform.
Having had problems getting the required modules working properly on some win32 and mac systems, I tend to avoid them.
Yes, your friends' email address does indeed work, and is indeed valid, as would an entire list of others I have, maintain, and work with, and will not pass my
simple (and admittedly ficokta) solution.
However, I would point out - *in general* - folks with addresses specifically designed for obfuscation tend to not want their email addresses to pass.
BTW - It's refreshing to know you are still you after all these years...keep the faith.
EEjack
| [reply] |
It's not just about obfuscation. There are people behind corporate email gateways that have no control over the fact that their address must have a local part that gets quotes around it, for example. You are harming a very real populus that you cannot see, and I am standing for their rights to use your services. I can't tell you the number of web forms I've tried to fill out with even just my tagging email address
of "merlyn.SOMETHING@stonehenge.com" so I can track where the address is sold,
and it gets rejected by some lame web programmers excuse for a program who has only seen the alphabet on the left side
of the "@".
So, this is not about obfuscation. That's a red herring. This is about real people, with real mail addresses that are far more characters than those that match \w. Do not shut them out just because you don't know one of them personally.
-- Randal L. Schwartz, Perl hacker
| [reply] |
BTW - It's refreshing to know you are still you after all these years...keep the faith.
Hmm. Depending on my mood, I can interpret this all the way from "good job, keep up the good work" down to "f**k you, I'm doing what I want, in spite of your
arrogant pitiful attempts at interference".
Since I can't tell what it is, and I am researching how online communities
interact, would you mind elaborating what range of emotion you attached (but didn't
express explicitly) in that statement? For the record, and for the research. Thank you.
-- Randal L. Schwartz, Perl hacker
| [reply] |
What about <root@astlavista.box.sk>?
Remember, even if an email address passes a
regex, you do not necessarily know that it is
indeed a VALID email address.
Email capt3043@yahoo.com if you don't believe me.
| [reply] [d/l] |
I agree it is not a perfect solution.
To account for all the possible email addresses would be very difficult, made improbably more twisted trying to verify them as you point out.
The closest I have gotten was a regex that pulled out the email, then attempted to send mail to the email account and stopping at the point where the smtp server would
accept data and dropping the connection. I did this because so many mail servers were denying vrfy.
However - now many mail servers are accepting *any* mail, then deciding whether or not to deliver or return. AOL is the big one doing this. I have my mail servers set up to do this
as well on some domains (using ruleset 6 IIRC) and catchalls that dump non-valid email into the bit bucket on my ntmailserver.
And honestly, I found my method, while functional, intrinsictly rude - so I stopped using it.
The very best way to verify is to try your best in parsing, send an email for validation and keep track of responses and bounces.
But thank you for bringing it up. The person who was asking didn't get my best answer, instead got my quick answer.
Perhaps a better example with better explanations would have been more appropriate on my part - or a link to one of the many other places
that would explain it better than I could. Unfortunately I have a difficult time explaining things well. It's a learning experience for everyone...:)
Until I can dig up a link or two...
#!/usr/bin/perl -w
@test = (
'0email user <emailuser@emailaddress.com>',
'1email user <email.user@emailaddress.com>',
'2email user <emailuser@email-address.com>',
'3email user <emailuser@mail.email-address.com>',
'4email user <email.user@email-address>',
'5email user <email.user@email.addres.scom>',
'6email user <email.user@emailaddresscom>'
);
foreach $temp (@test){
if ($temp =~ /\<([.-A-Za-z]+\@[.-A-Za-z]+\.[A-Za-z]{2,4}})\>/){
print "$1\n";
} else {
print "$temp failed \n";
}
}
This will account for *many* of the common email address forms you will run into (using the formatting provided - there as many possible formats for an email address as there are ..umm.. email addresses).
It doesn't account for lots of things, and as you can see, gives you a false positive for #5, but will get your list *real close*.
Thanks again for the gentle reminder jeffa. Much appreciated.
EEjack
| [reply] [d/l] [select] |