Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.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_Email - Fatal编程技术网

Php 联系人表单仅在我不输入电子邮件时发送

Php 联系人表单仅在我不输入电子邮件时发送,php,email,Php,Email,如果我将测试放在电子邮件字段中,它将发送,但使用实际的电子邮件地址,它将不起作用。我真的不明白为什么会这样 PHP代码: <?php $action=$_REQUEST['action']; if ($action=="") /* display the contact form */ { ?> <form action="" method="POST" enctype="multipart/form-data"> <inpu

如果我将测试放在电子邮件字段中,它将发送,但使用实际的电子邮件地址,它将不起作用。我真的不明白为什么会这样

PHP代码:

<?php
$action=$_REQUEST['action'];
if ($action=="")    /* display the contact form */
    {
    ?>
    <form  action="" method="POST" enctype="multipart/form-data">
    <input type="hidden" name="action" value="submit">
    Your name:<br>
    <input name="name" type="text" value="" size="30"/><br>
    Your email:<br>
    <input name="email" type="text" value="" size="30"/><br>
    Your message:<br>
    <textarea name="message" rows="7" cols="30"></textarea><br>
    <input type="submit" value="Send email"/>
    </form>
    <?php
    } 
else                /* send the submitted data */
    {
    $name=$_REQUEST['name'];
    $email=$_REQUEST['email'];
    $message=$_REQUEST['message'];
    if (($name=="")||($email=="")||($message==""))
        {
        echo "All fields are required, please fill <a href=\"\">the form</a> again.";
        }
    else{        
        $from="From: $name<$email>\r\nReturn-path: $email";
        $subject="Message sent using your contact form";
        mail("MAIL@MAIL.COM", $subject, $message, $from);
        echo "Email sent! You will be redirected to the home page in 5 seconds.";
        header('refresh:5;url=index.html');
        }
    }  
?>

尝试修改电子邮件标题:

$sender = "$name <$email>";
$from = "MIME-Version: 1.0"."\n";
$from .= "Content-type: text/html; charset=utf-8"."\n";
$from .= "Content-Transfer-Encoding: 8bit"."\n";
$from .= "From: $sender"."\n";
$from .= "Return-Path: $sender"."\n";
$from .= "Reply-To: $sender\n";
我建议考虑PHPMALLER类的源代码,参见和

这里需要一个空间吗?name您是否有权访问邮件日志以检查错误?