Outside the Cube (31)
Web publishing (134)
about DelphiFAQ (14)
perl CGI (65)
Web Hosting (270)
Handy function if an email field was filled out properly
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Question:I need to check whether a user filled out the email field with a valid email address. Any ideas?
Answer:The only way to prove it is valid is to send a confirmation email with some secret url and or code to that email address, have the user read the email and click on the URL that comes in it. That way you verify that the user provided an email that actually exists.
Sometimes you can rely on the user's strong interest to provide a valid email address or you simply do not want to wait until the user has completed this process.
And even if you send the confirmation email, it does not hurt to do a syntactical check. The following code checks if there is an @ and a dot in the email address.
Note that theoretically an email does not necessarily contain the @ sign - e.g. it could be coded as %64 (which corresponds to the @ symbol).