我的邮件功能有什么错误?

时间:2018-06-20 08:08:12

标签: php function email

我已经在服务器上编写了一个简单的php邮件功能,该错误显示了邮件未发送的错误,我还检查了邮件功能是否正常工作,它表明邮件功能正常工作,但是我的脚本无法正常工作低于

    <?php
    /*
     * Enable error reporting
     */
    ini_set( 'display_errors', 1 );
    error_reporting( E_ALL );

    /*
     * Setup email addresses and change it to your own
     */
     if(isset($_POST['send'])){
         var_dump($_POST);
     $from = "no-reply@skynetinfosolution.com";
    $to = $_POST['to'];
    $subject = $_POST['subject'];
    $message = $_POST['body'];
    $headers = "From:" . $from;

    /*
     * Test php mail function to see if it returns "true" or "false"
     * Remember that if mail returns true does not guarantee
     * that you will also receive the email
     */
    if(mail($to,$subject,$message, $headers))
    {
        echo "Test email send.";
        $headers .="MIME-Version: 1.0" . "\r\n";
         $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

    } 
    else 
    {
        echo "Failed to send.";
         //ror_get_last();


    }

     }
?>
        <form action="mail2.php" method="post">
    To<input type="email" name="to" placeholder="Enter email"><br/>
    Subject<input type="type" name="subject" placeholder="Subeject"><br/>
    Body<input type="text" name="body" placeholder="Body Message">
    <input type="submit" name="send" value="Send">
    </form>
    </body>
    </html>

0 个答案:

没有答案