TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Show Off (http://www.talkphp.com/show-off/)
-   -   PHP Script to Extract Email Address from any text (http://www.talkphp.com/show-off/1454-php-script-extract-email-address-any-text.html)

sunilbhatia79 11-14-2007 02:31 PM

PHP Script to Extract Email Address from any text
 
I have developed a function that you can embed in your PHP applications that will help you extract email addresses from a given piece of text.

Check it here:
http://www.sunilb.com/php/php-script...-from-any-text

Please leave behind comments for suggestions and questions.

Sunil

Salathe 11-14-2007 06:06 PM

Can you explain why you chose to tokenise the string over using regular expressions to extract the email addresses? Also, the patterns used to remove "invalid" characters and determine valid addresses are far from ideal. For example, they would allow _@-.zz but disallow me+test@domain.com (the first being an invalid address and the second a valid one).

Wildhoney 11-14-2007 06:41 PM

You know, Salathe, even I forget that the + in an email address is valid from time-to-time. Such as like if my email was adam@example.com, I could specify it as talkphp+adam@example.com, and it'll come right to my inbox at adam@example.com. Many registration forms don't actually check for duplicates based on this either, if they allow the + then often they would class it as a unique email address.

sunilbhatia79 11-15-2007 03:31 AM

Thank you guys... I will surely take your feedback and improve the script...

Thanks again

Salathe 11-15-2007 01:00 PM

Just to clarify, your use of the + sign within an email address is incorrect Wildhoney. Email sent to talkphp+adam@example.com would be routed through to talkphp@example.com. I very often use it to label things that I think will be spammy or to specify 'groups' which my mail software can then filter incoming mail by. Sadly, all too many websites refuse to accept that the + symbol is a valid character when used like this. :(

Thanks for listening Sunil, and good luck with your work on the script.

Wildhoney 11-15-2007 01:53 PM

Oh yes, I remember now. See how easy I forget this technique. I have used it in the past, admittedly, not in a while.


All times are GMT. The time now is 08:35 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0