Skip to main content

PHP's mail() results in a 500 Internal Server Error

Comments

4 comments

  • keat63
    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
  • cPanelMichael
    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
  • Rushmik
    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
  • cPanelMichael
    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.