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.

TABLE OF CONTENTS:
  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
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
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
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap

Dev Shed Tutorial Topics: