To validate an e-mail address by checking it's syntax, and looking up
the host name in DNS:
http://www.systeminetwork.com/article.cfm?id=17632
To validate an e-mail address by checking it's syntax with a regular
expression:
http://www.systeminetwork.com/article.cfm?id=52826
Both links require a membership for System iNetwork (but a free
"associate" membership should work.)
I strongly discourage anyone from trying to use SMTP to verify an e-mail
address because of the fact that there are SMTP servers out there that
just queue mail and forward it to a different server:
a) Sometimes this is done for virus scanning. The anti-virus appliance
receives all e-mail for a domain. It scans it. If it's safe, it
forwards it to the "real" e-mail server. The virus server doesn't know
all of the users who receive e-mail... it accepts any mail for the given
domain (the part after the @ in the address) whether the address is
correct or not. After it scans it, it fowards it to the real server. If
the address was wrong, the real server replies in e-mail.
b) The same as A, but spam checking instead of virus scanning.
c) The same as A, but just as a backup server in case the main server
goes down for some reason.
d) The same as A, but instead of a secondary/forwarding server, the main
server just sends e-mails for errors because the administrator prefers
it that way.
Thereofre, the SMTP verification (including the link provided by Josh
Diggs) will work sometimes for some sites, but not consistently for
everyone. Do not use it.
DNS verification is also tricky. It should work very well, but it only
checks the host name, not the userid. If, for some reason, the DNS
servers are down, or your connection to the internet is down or flaky,
the DNS lookup might fail for a valid host, and therefore it might say a
valid address is invalid. (The same is true of the SMTP method, but
that method has the much bigger problem that it's unreliable as
described above.)
There's really no way to reliably determine (programatically) if an
e-mail address is valid.
A syntax check -- such as the regular expression method -- is really
about the best you can do without running the risk of dumping valid
addresses and keeping invalid ones.
Jonathan Mason wrote:
Hi Tim
Scott Klement produced an email validation routine back in 2003 that would
first check the syntax of the email address and then look for an MX record
to determine if the domain name was real.
I can't find the link for the tool, perhaps Scott will jump in with the
address.
All the best
Jonathan
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of tim
Sent: 11 January 2008 15:24
To: 'RPG programming on the AS400 / iSeries'
Subject: email/SMTP validation
I am interested in validating an email address. No just the syntax but if
it's a valid email address. I've heard that that's called "smtp validation".
Has anyone done this who can give some suggestions?
Thanks
As an Amazon Associate we earn from qualifying purchases.