PHP邮件()后出现500错误

PHP邮件()后出现500错误,php,sendmail,Php,Sendmail,更新 我能够从我的客户那里获得托管信息,并联系了支持人员,显然目前主机邮件功能存在问题,他们正在制定解决方案。将等待,看看这是否是导致此问题的原因,并将报告。 结束更新 我正试图建立一个简单的联系形式,将发送电子邮件。我将表单操作设置为下面的PHP文件 电子邮件被发送,但用户体验以500错误结束,而不是将用户发送到确认页面 如果我注释掉邮件部分,那么表单会成功地将用户重定向到确认页面,但当然不会发送电子邮件 该网站托管在GoDaddy上,我没有访问托管帐户的权限,但如果需要,我可以尝试获取该帐户

更新 我能够从我的客户那里获得托管信息,并联系了支持人员,显然目前主机邮件功能存在问题,他们正在制定解决方案。将等待,看看这是否是导致此问题的原因,并将报告。 结束更新

我正试图建立一个简单的联系形式,将发送电子邮件。我将表单操作设置为下面的PHP文件

电子邮件被发送,但用户体验以500错误结束,而不是将用户发送到确认页面

如果我注释掉邮件部分,那么表单会成功地将用户重定向到确认页面,但当然不会发送电子邮件

该网站托管在GoDaddy上,我没有访问托管帐户的权限,但如果需要,我可以尝试获取该帐户

以下是PHP代码:

<?php

$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['CITY'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$email = $_POST['email'];
$howdidyouhear = $_POST['hear_about'];
$notifyshow = $_POST['notify_shows'];
$notifyonline = $_POST['notify_online'];
$interest_jewelry = $_POST['Interest_jewelry'];
$interest_prints = $_POST['interest_prints'];
$interest_folkart = $_POST['interest_folkart'];
$interest_indian = $_POST['interest_indian'];
$interest_closeouts = $_POST['interest_closeouts'];
$interest_other = $_POST['interest_other'];
$interest_other_text = $_POST['interest_other_text'];
$spamvalid = $_POST['validate'];
$honeypot = $_POST['website'];

//Spammer Handling
if ($honeypot!=null){echo 'You have been flagged as a spammer, please go away!'; exit;} 

if ($spamvalid != '357'){
    echo "
    <script>
        function goBack() {
            window.history.back()
        }
    </script>
    You didn't enter the correct number at the bottom of the form.  Please try again.<br><button onclick='goBack()'>Go Back</button>";
    exit;
}

//START EMAIL

//Body
$mailbody="Name: {$name}\n\nAddress: {$address}\n\nCity: {$city}\n\nState: {$state}\n\nZip: {$zip}\n\nEmail: {$email}\n\nHow did you hear about us?: {$howdidyouhear}\n\nWould you like to be notified when we will be doing a show in your area?: {$notifyshow}\n\nWould you like to receive email notifications of special sales and online events?: {$notifyonline}\n\nWhat brought you to mishuganah.com?: {$interest_jewelry} {$interest_prints} {$interest_folkart} {$interest_indian} {$interest_closeouts} {$interest_other}: {$interest_other_text}\n\n";

//Send Email
mail('matt.rodela@gmail.com','New submission from Mishuganah.com', $mailbody, "From:{$email}\r\n" );

header("Location: http://".$_SERVER["HTTP_HOST"]."/mailing_list/confirmation_page.htm");

?>

我是PHP的新手,所以请详细解释你的解决方案。谢谢

原来这是戈达迪那边的一个问题,已经解决了。表格正在运行。显然代码没有问题

Use phpMailer instead of php mail() function below you will find reasons not to use built in php mail function

In some cases, mails send via PHP mail() did not receive the recipients although it was send by WB without any error message. The most common reasons for that issue are listed below.

    wrong format of mail header or content (e.g. differences in line break between Windows/Unix)
    sendmail not installed or configured on your server (php.ini)
    the mail provider of the recipeint does not allow mails send by PHP mail(); common spam protection

Errors in the format of header or content can cause that mails are treated as SPAM. In the best case, such mails are transfered to the spam folder of your recipient inbox or send back to the sender. In the worst case, such mails are deleted without any comment. If sendmail is not installed or not configured, no mails can be send at all.

It is common practice by free mail provider such as GMX, to reject mails send via the PHP function mail(). Very often such mails are deleted without any information of the recipient.

感谢各位的建议,我现在学到了一些关于sanatize和筛选输入的知识。

如果您想测试,请在此处填写表格:打开文件后立即将错误报告添加到文件顶部您是否尝试过使用“@mail”,而不是仅使用“mail”?@WisdmLabs这主意太棒了!只是隐藏错误,而不是修复错误。可能出现什么问题?什么是服务器配置?如果您的服务器没有邮件服务器设置和/或php_ini邮件设置不正确,则会出现错误。还要过滤您的输入这样做的最佳方式是什么?$name=htmlentities$_POST['name'];