library/Garp/Util/String.php
static public function linkEmailAddresses($text, array $attribs = array()) {
        $htmlAttribs = array();
        foreach ($attribs as $name => $value) {
            $htmlAttribs[] = $name . '="' . $value . '"';
        }
        $htmlAttribs = implode(' ', $htmlAttribs);
        $htmlAttribs = $htmlAttribs ? ' ' . $htmlAttribs : '';

        $regexp = '/[a-zA-Z0-9\.-_+]+@[a-zA-Z0-9\.\-_]+\.([a-zA-Z]{2,})/';
        $text = preg_replace($regexp, "<a href=\"mailto:$0\"$htmlAttribs>$0</a>", $text);
        return $text;
    }
static public function linkEmailAddresses($text, array $attribs = array()) {
        $htmlAttribs = array();
        foreach ($attribs as $name => $value) {
            $htmlAttribs[] = $name . '="' . $value . '"';
        }
        $htmlAttribs = implode(' ', $htmlAttribs);
        $htmlAttribs = $htmlAttribs ? ' ' . $htmlAttribs : '';

        $regexp = '/[a-zA-Z0-9\.-_+]+@[a-zA-Z0-9\.\-_]+\.([a-zA-Z]{2,})/';
        $text = preg_replace($regexp, "<a href=\"mailto:$0\"$htmlAttribs>$0</a>", $text);
        return $text;
    }
static public function linkEmailAddresses ( $ text , array $ attribs = array ( ) ) { $ htmlAttribs = array ( ) ; foreach ( $ attribs as $ name => $ value ) { $ htmlAttribs [ ] = $ name . '="' . $ value . '"' ; } $ htmlAttribs = implode ( ' ' , $ htmlAttribs ) ; $ htmlAttribs = $ htmlAttribs ? ' ' . $ htmlAttribs : '' ; $ regexp = '/[a-zA-Z0-9\.-_+]+@[a-zA-Z0-9\.\-_]+\.([a-zA-Z]{2,})/' ; $ text = preg_replace ( $ regexp , "<a href=\"mailto:$0\"$htmlAttribs>$0</a>" , $ text ) ; return $ text ; }
Link email addresses

@param string $text
@param array $attribs HTML attributes
@return string
Link email addresses