Adding  around link or mail
You can configure one of your text formats to use the "Convert URLs into links" filter, then to apply that text format to some text you can use the check_markup() function like this:

// Run text through the Filtered HTML text format.
$formatted_text = check_markup($original_text, 'filtered_html');


You can change 'filtered_html' to be whichever text format you want to apply.
Note that it will run all the other filters of that text format on the text also.