to troubleshoot further, changer the following line:
$GoToPage = "thanks.php";
$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:
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.