Home arrow PHP arrow Page 4 - Building A PHP-Based Mail Client (part 1)

Fully Function-al - PHP

Ever wondered how Web-based mail clients work, or what happens toyour email after you hit the "Send" button? This three-part case studydelves into the wild and wacky world of Web-based email applications, usingPHP's built-in POP3 functions to build an email client suitable forrerieving POP3 email via a Web browser. In this introductory segment -connecting to a POP3 server, logging in and out, retrieving message headersfor display, and deleting messages off the server.

  1. Building A PHP-Based Mail Client (part 1)
  2. Requiring Immediate Attention
  3. Start Me Up
  4. Fully Function-al
  5. Opening Up
  6. Calling The Exterminator
  7. Back To Square One
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 55
January 02, 2002

print this article


Before moving on, a quick word about the "functions.php" file include()d in the script you just saw.

"functions.php" is a separate file containing useful function definitions. Every time I write a function that might come in useful elsewhere in the application, I move it into "functions.php" and include that file in my script.

An example of this is the validate_email() function used in the script above - here's what it looks like:

<? // check if email address is valid function validate_email($val) { if($val != "") { $pattern = "/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/"; if(preg_match($pattern, $val)) { return true; } else { return false; } } else { return false; } } ?>
Again, this is fairly simple - I'm using PHP's pattern matching capabilities to verify that the email address supplied conforms to the specified pattern. The function returns true or false depending on whether or not the match was successful.

>>> More PHP Articles          >>> More By icarus, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- 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: