good tutorial.

below line:
echo "Mail sent to $to";

should be imo:
echo "Mail sent to ".$to;


cheers mate.