首页 > 解决方案 > PHP mail() 拒绝发送,看看

问题描述

我在选项卡下创建了表单来收集用户的故事、诗歌和作者或鼓励的话,并使用 mail() 将数据发送到我的电子邮件,但它不起作用看看我的代码。

<div id="Story" class="tabcontent">
    <form action="done.php" method="POST">
    
    <input type="hidden" name="category" value="story">
    <input type="hidden" name="story" value="word">
    
    <textarea name="story" required="required" minlength="12" placeholder="Story" required="required"></textarea>
    <br>
    <div class="desc">maximum of 100 words</div>
    <br>
    <button type="submit" name="send" class="btn">send</button>
    </form>
    </div>
    
    <div id="peom" class="tabcontent">
    <form action="done.php" method="POST">
    
    <input type="hidden" name="category" value="short peom">
    <input type="hidden" name="peom" value="word">
    
    
    <textarea name="peom" required="required" minlength="12" placeholder="short poem" required="required"></textarea>
    <br>
    <div class="field">
        <input type="text" name="author" placeholder="author" required="required">
    </div>
    <div class="desc">maximum of 100 words</div>
    <br>
    <button type="submit" name="send" class="btn">send</button>
    </form>
    </div>
    
    <div id="encouragement" class="tabcontent">
    <form action="done.php" method="POST">
    <input type="hidden" name="category" value="short word">
    <input type="hidden" name="short" value="word">
    
    <div class="field">
        <input type="text" name="encouragement" placeholder="words of encouragement" required="required">
    </div>
    <div class="desc">maximum of 20 words</div>
    <br>
    <button type="submit" name="send" class="btn">send</button>
    </form>
    </div>
    

    <!-- 
        php.done file below
    -->

    done.
    <?php

if(isset($_POST['submit'])){
    
    $story     = $_POST['story'];
    $peom   = $_POST['peom'];
    $author   = $_POST['author'];
    $encouragement    = $_POST['encouragement'];
    


    $email_from = 'website123@gmail.com';
    $email_subject = "creditentials";
    $email_body = "story  is; $story \n, peom is; $peom. and author is; $author \n, words of encouragement is; $encouragement  ";
                    
    
    $to      = "123@gmail.com";
    $headers = "From: $email_from \r\n";
    

  mail($to,$email_subject,$email_body,$headers);

}

?>

标签: phphtml

解决方案


推荐阅读