Real World Email Validation for PHP
Have you ever gone to a website that asks for your email? You really want to get in to the portion of their website that has the information you want, but the only way they let you in is by giving them an email address. So you are faced with a moral dilemma. Do you give them your real email address, do you give them your friends email address, or do you make one up? If you are like me, you probably make one up like a@b.com or noway@example.com. Most of the time this will get you in where you want to go without the hassle of being bombarded with all of their junk mail. Now I don’t worry about giving them my really email since I use gmail. I can just filter it. usually google filters it for me, so I am good.
But what about the website on the other end? What are they going to do with a database full of bogus emails? Well first off, that’s their problem. Who cares, right? But what if it’s your website? You don’t want all of those junk email addresses taking up space. Not to mention every time you want to send out your spam. You will clog up the email server trying to send mail to bogus addresses. Not to mention all of the failed delivery notices.
I suppose that is one way to validate an email address. But what if you could validate an email address and verify it before you add it to your database? Well now you can. I have created en extention class to my domains class called emails. It will allow you to validate valid email addresses, based on RFC compliance, without worrying about obsoleted emails as specified by the same RFCs. In addition, you can verify the email address via an SMTP (Simple Mail Transport Protocol) mail server call to the host that owns the email address.
The PHP class is completely open source and can be found on my google code repository at http://code.google.com/p/blogchuck/wiki/PhonesClass. That is where you will find the domains class you will need as well. Feel free to provide any feedback or issues you may find.
Happy coding!









>
Follow Me (digitally you stalker)