php: обернуть все email в html документе ссылками mailto:
function htmlizeEmails($text){ preg_match_all('/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})/',$text,$potentialEmails,PREG_SET_ORDER); $potentialEmailsCount=count($potentialEmails); for($i=0;$i<$potentialEmailsCount;$i++){ if(filter_var($potentialEmails[$i][0],FILTER_VALIDATE_EMAIL)){ $text=str_replace($potentialEmails[$i][0],'<a href="mailto:'.$potentialEmails[$i][0].'">'.$potentialEmails[$i][0].'</a>',$text); } } }
Использование:
$str="Send me an email to [email protected]."; echo htmlizeEmails($str); //Echoes "Send me an email to <a href="mailto:[email protected]">[email protected]</a>."
http://stackoverflow.com/questions/9763606/detecting-emails-in-a-text