|Subject:||Re: How to test of e-mail address is valid|
|Posted by:||Remy Lebeau (TeamB) (firstname.lastname@example.org)|
|Date:||Mon, 9 May 2005|
"Nols Smit" <nols_sm…@yahoo.com> wrote in message
> I use the TidSMTP.QuickSend command in an IntraWeb application
> to send email. How do I test if the e-mail address is valid before I
> send the mail?
The short answer is you cannot. Not entirely, anyway, unless you want to
don't mind doing in extra work on your part.
Sure, you can check the syntax of the address, like loki suggests, but that
doesn't tell you whether the address is actually valid, only that it is
A more reliable approach would be to query the SMTP server directly, via the
TIdSMTP.Verify() method. However, that would require you to first parse the
domain portion out of the address, then do a DNS query for the MX record of
that domain, then connect to the specified server and send it the username
portion of the original address via Verify(). Even then, that will tell you
one of three things: 1) the username is known and local to that server; 2)
the username is known but belongs to a different server that the queried
server knows how to forward messages to; or 3) the username causes an error,
which means the address is most likely invalid.
How to test of e-mail address is valid posted by Nols Smit on Mon, 9 May 2005