为什么我不能使用以下php文件。我的托管使用Windows主机。 提交时有500个内部错误。但我可以在另一台服务器上提交它。 如果有人能帮助我,我感激不尽。
<?php
header('Content-Type: text/html; charset=utf8');
if(!isset($_POST['submit']))
{
}
$name_c = $_POST['name_c'];
$name_e = $_POST['name_e'];
$visitor_email = $_POST['email'];
$phone = $_POST['phone'];
$email_from = 'reg@email.com';//<== update the email address
$email_subject = 'New Form submission';
$email_body = "INfo: <br>
name: $name_c.<br>";
$to = "myemail@email.com";//<== update the email address
//$headers = "From: Me \r\n";
//$headers .= "Reply-To: $email_from \r\n";
$sCharset = 'utf-8';
$headers = "Content-type: text/html; charset=$sCharset\r\n" .
"From: Fuzinewsletter \r\n" .
"Reply-To: $email_from \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: thank-you.html');
";
?>
答案 0 :(得分:0)
文件末尾有";
导致解析错误:
解析错误:语法错误,意外的文件结束,期望变量 (T_VARIABLE)或$ {(T_DOLLAR_OPEN_CURLY_BRACES)或{$(T_CURLY_OPEN)
尝试删除它。
答案 1 :(得分:0)
你可以看到很多垃圾代码......使用此方法发送电子邮件。
使用error_reporting(E_ALL);
或检查 Apache错误日志
function sendMail($email, $subject, $message)
{
$supportEmail = 'info@abc.com';
$from = 'Abc';
$msg = $message;
$from = str_replace(' ', '-', $from);
$frm = $from.' <'.$supportEmail.'>';
preg_match("<(.*)@(.*\..*)>", $frm, $match);
///////////////////Headers/////////////////
$hdr='';
$hdr.='MIME-Version: 1.0'."\n";
$hdr.='content-type: text/html; charset=iso-8859-1'."\n";
$hdr.="From: {$frm}\n";
$hdr.="Reply-To: {$frm}\n";
$hdr.="Message-ID: <".time()."@{$match[2]}>\n";
$hdr.='X-Mailer: PHP v'.phpversion();
$x=@mail($email, $subject, $msg, $hdr);
if($x==0)
{
$email=str_replace('@','\@', $email);
$hdr=str_replace('@','\@',$hdr);
$x=@mail($email, $subject, $msg, $hdr);
}
return $x;
}