PHP's mail() results in a 500 Internal Server Error
I am running the following code off a Cloud VPS hosted by A2Hosting, which was setup with WHM and CPanel. I cannot guarrantee that I did any of this properly, but so far the site has been running fine, right up to sending an email. I am hoping you can help me troubleshoot, as I have googled around for several hours to no avail.
I have spoken to the A2Hosting support team and they informed me that the mail() function is not disabled. They also referred me to this forum.
The code I am running to test the function is as follows:
I am very new to web hosting, so please "explain like I'm five". Please let me know if you need any further information (and where I might find it), and thank you for any and all help.
I am very new to web hosting, so please "explain like I'm five". Please let me know if you need any further information (and where I might find it), and thank you for any and all help.
-
Here's one i wrote, to email me when a customer completes an online form. Maybe you can pick some bones out of it. The secret code is a simple captcha [PHP]from@yourdomain.com"; $EmailTo = "[COLOR="#FF0000">to@yourdomain.com"; $Subject = "[COLOR="#FF0000">your subject"; $Name = Trim(stripslashes($_POST['Name">)); $Company = Trim(stripslashes($_POST['Company">)); $Tel = Trim(stripslashes($_POST['Tel">)); $Email = Trim(stripslashes($_POST['Email">)); $Message = Trim(stripslashes($_POST['Message">)); $answer = Trim(stripslashes($_POST['answer">)); // validation $validationOK=true; if (!$validationOK) { print "http://www.yourdomain.com/a-fail-message.html">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Company: "; $Body .= $Company; $Body .= "\n"; $Body .= "Tel: "; $Body .= $Tel; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; if (Trim(stripslashes($_POST['answer">))=='[COLOR="#FF0000">secret-code'){ // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "http://www.yourdomain.com/thankyou.html">"; }else{ print "http://www.yourdomain.com/a-fail-message.html">"; } } else{ print "http://www.yourdomain.com/a-fail-message.html">"; }[/PHP] 0 -
Hello :) What's the specific error message you notice under the "Error Log" option in cPanel when the "500 Internal Server Error" message presents itself in your browser? Thank you. 0 -
Thank you Michael! In all my Googling around I forgot all about my error log, and the symptoms I was searching were leading to all sorts of horror stories. I had not set the file permissions. Yeah. You can close this thread. Thanks again. :) 0 -
I am happy to see you were able to resolve the issue. Thank you for updating us with the outcome. 0
Please sign in to leave a comment.
Comments
4 comments