Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
电子邮件脚本不工作(PHP)_Php - Fatal编程技术网

电子邮件脚本不工作(PHP)

电子邮件脚本不工作(PHP),php,Php,所以我写了一个电子邮件脚本,但由于某种原因,它现在不起作用了,我甚至不记得更改过它。。。我想我更改了一个echo输出,但是当我将它恢复到旧版本时,它仍然不起作用,所以我不确定我做错了什么,我将它通过php检查程序,结果它返回,因为代码很好 这是我的密码,请帮忙 <?php if(isset($_POST['username'])) { function died($error) { // your error code can go here echo "We are v

所以我写了一个电子邮件脚本,但由于某种原因,它现在不起作用了,我甚至不记得更改过它。。。我想我更改了一个echo输出,但是当我将它恢复到旧版本时,它仍然不起作用,所以我不确定我做错了什么,我将它通过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
}
?>

//邮件($emailto、$emailsubject、$email\u message、$headers);
?>
检查了代码

它在发送电子邮件

我发现的唯一问题是,您在错误的位置关闭了一个php标记


删除注释邮件功能之前的结束标记。

在此处发布错误?请定义“不工作”!你在哪里使用它?在共享主机或本地主机上?没有错误,只是不发送电子邮件?没有错误从它回来。。。这就是我困惑的原因!检查邮件帐户的垃圾邮件文件夹
?>

//mail($emailto, $emailsubject, $email_message, $headers);  
?>