Miguel said:
I need to know wether a given e-mail address ("(e-mail address removed)") is
valid - not if it's simply syntactically correct (that's trivial to
verify), but wether it corresponds to an actual, live, address.
A great many addresses are conformant to the email standards, and don't
look like what you expect.
Is there some way to do this? I'm not sure myself how to approach this
problem.
If you try to do it in the general case, you will surely exclude
otherwise valid addresses.
Now, there are compromises you can make.
1. If you're assigning the email addresses in the first place, you can
of course be brutal in your validation.
2. If you don't care about clients who will, perhaps deliberately, use
valid email addresses that won't pass your validation, is that
acceptable to your business situation?
3. If you do care, and you need to accept only email addresses that are
strictly valid without accidentally excluding valid ones, you need to
fully understand RFC2822.
Now, I would not even try to do something like, use an email address
with a long LDAP identifier on the left hand side to register for a
customer service or blog site. But if you set up something important,
you might learn the hard way that there are lots of people, e.g.,
government employees, that have email addresses that would look very
strange if all you're expecting is "(e-mail address removed)"
Honestly, the only *right* way to "validate an email address" is to send
an email to the address, which provides a backchannel for validation.
Then you can accept any email address that can be used in a SMTP RCPT
TO: and that's all the validation you need.
You will find regular expressions out there that do a pretty good job of
vetting an email with a minimum of false rejects, but you need to
understand the risks, if you or your users care about them.
I have several correspondents who work in legislative offices whose
official email addresses follow a form that looks something like
"Last_First/OU=department/ORG=role%
[email protected]"
Many offices are infected with certain groupware suites and their email
gateways, mainframe enterprise mail systems to internet gateways, names
that are directly mapped to all kinds of directory systems, which means
that it often is important to properly handle email address that don't
resemble the typical address style of the common personal internet user.
One of my professional email addresses is 21 characters long, and has a
dotted component on the left hand side, in the form of
"(e-mail address removed)"
Entirely valid, required to be used for certain kinds of business, and
rejected by many well-meaning systems. This address isn't even
especially weird.
Be careful, unless it's your intention to be hostile and a bastard
