to troubleshoot further, changer the following line:
$GoToPage = "thanks.php";
to:
$GoToPage = "";
so that the page will not be redirected after the email is sent.
Then add the following code at line 1 to turn on error reporting:
<?php
error_reporting(E_ALL);
ini_set('display_errors','on');
?>
next, on the bindings tap, expand the Uploaded Files Global Status group and add the Debug info binding to your page.
Post back the results of the debug info and any errors that may be reported.