- What is is_email()?
- is_email() is a PHP function to validate an email address. Simple, no?
- Since starting to write
is_email() I've learned more than I ever wanted to about internet RFCs and how domain names work and how SMTP works.
- Trust me, you don't need to know all that stuff - just download
is_email() and use it. It's free and it's open source
- I compiled over 200 unit tests and compared
is_email() against all the other email validators I could find. It scored 100%. None of the others got above 80% except for Cal Henderson's (we co-developed the unit tests and he rewrote his validator at the same time as I was finishing
- What RFCs do I need to understand?
- None, that's the point. I've done it for you.
- If you really want to get into it then read my article
- Is it perfect?
- No, it doesn't do international domain names.
- The other issue is that the RFCs are not very good. There are some edge cases that are valid but not likely in the real world.
- So I found myself sometimes making a choice between strict RFC compliance and real-world usefulness. I'm not happy with that compromise and I'd like to do a new version where that choice is parameterised and you, the website developer, get to decide.
- At the moment I haven't got time to do this myself. But it's open source software - why don't you have a go yourself? I'm happy to check in any code that passes all the unit tests.