【发布时间】:2016-05-30 22:44:51
【问题描述】:
我在使用联系表单时遇到了 PHP 错误,该表单一直运行良好,直到客户说他们一周以来都没有收到电子邮件。作为一个朋友帮我做后端,他现在不能问,我想问你是否可以给我一个提示,我需要修复什么。
错误:
`[2016 年 2 月 17 日星期三 16:43:44] [警告] [客户端 37.24.118.150] mod_fcgid:stderr:PHP 注意:未定义变量:/var/www/vhosts/wscgmbh.de/httpdocs/php 中的标头/contact-form-handler.php 第 29 行,referer:http://www.wscgmbh.de/contact.html
[2016 年 2 月 17 日星期三 16:43:44] [警告] [客户端 37.24.118.150] mod_fcgid:stderr:PHP 警告:mail():在 /var/www/vhosts/wscgmbh 的 Additional_header 中发现了多个或格式错误的换行符.de/httpdocs/php/contact-form-handler.php 第32行,referer:http://www.wscgmbh.de/contact.html
[2016 年 2 月 17 日星期三 16:45:18] [警告] [客户端 37.24.118.150] mod_fcgid:stderr:PHP 注意:未定义变量:/var/www/vhosts/wscgmbh.de/httpdocs/php/ 中的标头第29行的contact-form-handler.php,referer:http://www.wscgmbh.de/contact.html
[2016 年 2 月 17 日星期三 16:45:18] [警告] [客户端 37.24.118.150] mod_fcgid:stderr:PHP 警告:mail():在 /var/www/vhosts/wscgmbh 的 Additional_header 中发现了多个或格式错误的换行符.de/httpdocs/php/contact-form-handler.php 第32行,referer:http://www.wscgmbh.de/contact.html
[2016 年 2 月 17 日星期三 17:02:25] [警告] [客户端 37.24.118.150] mod_fcgid:stderr:PHP 注意:未定义索引:/var/www/vhosts/wscgmbh.de/httpdocs/php/ 中的名称第 12 行的contact-form-handler.php
[2016 年 2 月 17 日星期三 17:02:25] [警告] [客户端 37.24.118.150] mod_fcgid:stderr:PHP 注意:未定义索引:/var/www/vhosts/wscgmbh.de/httpdocs/php/ 中的电子邮件第 13 行的contact-form-handler.php
[2016 年 2 月 17 日星期三 17:02:25] [警告] [客户端 37.24.118.150] mod_fcgid:stderr:PHP 注意:未定义索引:/var/www/vhosts/wscgmbh.de/httpdocs/php/ 中的消息第 14 行的contact-form-handler.php
[Thu Feb 18 09:40:15 2016] [warn] [client 213.23.122.15] mod_fcgid:stderr:PHP 注意:未定义变量:/var/www/vhosts/wscgmbh.de/httpdocs/php/ 中的标头第29行的contact-form-handler.php,referer:http://www.wscgmbh.de/contact.html
[Thu Feb 18 09:40:15 2016] [warn] [client 213.23.122.15] mod_fcgid:stderr:PHP 警告:mail():在 /var/www/vhosts/wscgmbh 的 Additional_header 中发现多个或格式错误的换行符.de/httpdocs/php/contact-form-handler.php 第32行,referer:http://www.wscgmbh.de/contact.html`
这是一直工作的表单处理程序的代码,但突然不工作了
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8" />
<?php
$errors = '';
$myemail = 'service@wscgmbh.de';
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z] {2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Sie haben eine neue Nachricht von: $name";
$email_body = "Sie haben eine neue Nachricht erhalten, hier sind die Details: \n\nName: $name \nEmail: $email_address \nNachricht: \n$message";
$headers [] .= 'From: WSC-Kontaktformular' . "\r\n";
$headers [] = "Antworten Sie: {$email_address}";
mail($to,$email_subject,$email_body,implode("\r\n",$headers));
//redirect to the 'thank you' page
echo '<script>
alert("Danke für Ihre Nachricht. Wir werden uns bald bei melden!");
window.location = "http://www.wscgmbh.de"
</script>';
}
?>
我不是专家和 PHP,所以我真的希望有人可以帮助我! 提前非常感谢您!!!
【问题讨论】:
-
我不久前发布了一个答案,但注意到您的代码中有其他内容,在标题中使用
Antworten Sie:似乎转换为Reply (to):。我已在答案底部附近编辑了关于它的答案,您需要在 Edit... 下重新加载它