You don't need another query for the id. It's already in $result.
$id = mysql_result($result,0,"id");
That would do the same thing, although it seems your problem might be in the SQL.
For debugging purposes, change it to
$query = "SELECT * FROM mail WHERE touser='$username'";
$result = mysql_query($query)
or die(mysql_error());
Do that and echo $query, and you'll probably see what's wrong right away.