所以我写了一个电子邮件脚本,但由于某种原因,它现在无法正常工作,我甚至不记得更改它...我想我改变了一个回声输出但是当我把它还原回旧时版本它仍然没有工作所以我不知道我做错了什么,我把它通过一个PHP检查器,它回来了,因为代码很好!
这是我的代码,请帮助!
<?php
if(isset($_POST['username'])) {
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['username']) ||
!isset($_POST['emailto']) ||
!isset($_POST['emailsubject']) ||
!isset($_POST['emailmessage'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$username = $_POST['username']; // required
$emailto = $_POST['emailto']; // required
$emailsubject = $_POST['emailsubject']; // required
$emailmessage = $_POST['emailmessage']; // required
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message = clean_string($emailmessage);
$email_message .= "\n\nNOTE: Sent from a ComputerCraft User (Using L2P Live Email Client).\n";
// create email headers
$headers = "From: " . $username ."@dannysmc.com \r\n".
'Reply-To: ' . $username . '@dannysmc.com '."\r\n" .
"Return-Path: email_catcher@dannysmc.com\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($emailto, $emailsubject, $email_message, $headers)){
echo 'TRUE';
}else{
echo '<pre>';
print_r(error_get_last()); //it will show you the error. Remove it on production
}
?>
//mail($emailto, $emailsubject, $email_message, $headers);
?>
<?php
}
?>
答案 0 :(得分:0)
检查代码。
发送电子邮件。
我发现的唯一问题是,你在错误的地方关闭了一个php标签。
?>
//mail($emailto, $emailsubject, $email_message, $headers);
?>
在评论邮件功能之前删除结束标记。