Ho risolto!

Bastava sostituire
if (strpos($mail,$testo))
con
if (eregi($testo, $mail))