我已经在godaddy上托管了一个网站,该网站的联系表单带有PHP的后端代码,我一点也不擅长PHP,我搜索并发现了以下代码,该代码应该可以使表单起作用并将邮件发送至网站访问者注册他的详细信息时提到的电子邮件,但是javascript显示它已成功发送,但是没有任何内容发送到邮箱。
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$mail_to = 'info@domaintest.com';
$subject = 'Message from a site visitor '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
$mail_status->Host = "localhost";
$mail_status->Port = 25;
$mail_status->SMTPDebug = 0;
$mail_status->SMTPSecure = "none";
$mail_status->SMTPAuth = false;
$mail_status->Username = "";
$mail_status->Password = "";
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'contact.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to info@jamallandscaping.com');
window.location = 'contact.html';
</script>
<?php
}
?>
我联系了Godaddy支持人员,他们说这是代码问题