change this line:
if($test = @mail($to, $subject, $message, $headers))
to this
if($test == @mail($to, $subject, $message, $headers))
that should work.
i didn't know, but mail() returns a bool value (true or false) if the email was sent successfully, so that means that the the variable $test must have a boolean value (true/false), otherwise, it will always return false.
what you were doing was putting the result of mail into the value of $test, in otherwords you were giving $test a value as oppose to comparing its value... just a simple equal sign!
hope that helps.