|Ned Batchelder : Blog | Code | Text | Site|
Email validation in PHP
» Home : Blog : January 2006
Naturally, fixing a bug in my comment system and mentioning it here yesterday merely encouraged the quiet malcontents to bring up their petty annoyances! I'm kidding: keep the bug reports coming. Platypus pointed out that the email validation didn't deal properly with his domain name.
So I've improved the email validation code. I know what a lot of you are thinking: why validate the email at all? I do it because it's a good way to prevent spam. Maybe someday I'll get rid of it, but for now it stays.
The problem in Platypus's case is that I look up MX records for the domain, and pl.atyp.us doesn't have one, but atup.us does. This is the code I'm now using:
Anyone else have a complaint?
Updated: I've since improved the code to deal with some of the issues in the comment thread here: Email validation again.