Home arrow PHP arrow Email Address Verification with PHP

Email Address Verification with PHP

Many applications in the field of Web development need to validate email addresses. While this can be done in a variety of ways, one simple but effective way involves writing your own functions in PHP. Alejandro Gervasio explains this approach.

TABLE OF CONTENTS:
  1. Email Address Verification with PHP
  2. Validating the proper format of an email address
  3. Validating email domains with checkdnsrr()
  4. Customizing checkdnsrr()
  5. Using getmxrr() for validation
  6. Empowering validation with fsockopen()
By: Alejandro Gervasio
Rating: starstarstarstarstar / 215
February 08, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Within the huge and fascinating field of Web development, one of the most common tasks that many applications have to deal with is, undoubtedly, verifying whether a user email address is valid. Certainly, this should sound very familiar to most Web developers, whether they are setting up their first consciously-coded script or implementing full-blown applications required to handle more complex processes. Whatever the case, validating a visitor's email address to see if it belongs to a real domain is always a good step to help you avoid, at least partially, several possible problems that arise when applications are receiving incoming bogus data. From cluttering up databases with invalid information, to sending newsletters or similar content to email addresses at nonexistent domains, headaches are surely going to come up from receiving fake email.

Several approaches can be taken to address the problem, depending on the level of complexity desired for the validation itself. If the application is going to make use of a basic level of validation, a quick-and-dirty way to handle the situation might be to implement a simple PHP function that performs pattern matching to a standardized email address format, as we have seen many times. However, when a deeper and more complex validation is required, we should take a look at well-trusted validation classes, such as Pear’s HTML_Quick Form class, or many other validation classes widely available out there.

The third option involves writing our own set of functions for in-deep email address checking, which can be considered an intermediate solution between the two above described. This approach is versatile and portable enough to be used whether we want to expand basic validating functions or add extra functionality to existing classes.

In this article, we’ll develop a reusable step-by-step solution to validate a user's email address as accurately as possible, in an attempt to save some work the next time an application needs to check for email validity. The process will show the power of some interesting PHP built-in network functions, as well as demonstrate how to reduce noticeably the possibilities of dirtying our applications with user-supplied bogus email.



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: