This PHP function will extract an email address from a string and put it into a clickable link:
function extractEmail( $data )
{
if ( preg_match( "/[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}/i", $data, $email ) )
{
$replacement = '<a href="mailto:' . $email[ 0 ] . '" target="_blank">' . $email[ 0 ] . '</a> ';
$data = preg_replace( "/[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}/i", $replacement, $data );
}
return $data;
}
To use it create PHP file and add there a test entry (but not forget to place the function above in it):
<?php
echo extractEmail("Some text goes here before mail@mail.com and some text here goes after");
?>