php中的mail()给出了500个内部服务器错误

时间:2017-11-23 05:27:32

标签: php email

我收到500个内部服务器错误的邮件ID,它不像test@test.com那样存在。我该怎么办呢。 我用try catch但仍然存在错误。但对于真正的邮件ID邮件发送和重定向到谢谢页面。 请帮忙。

if(isset($_POST["submit_msg"]))
{
    try{
        $contact_name=mysqli_real_escape_string($mysqli,$_POST["contact-name"]);
        $contact_email=$_POST["contact-email"];
        $ph=$_POST["contact-subject"];
        $msg=mysqli_real_escape_string($mysqli,$_POST["contact-message"]);

        $insert_query="insert into contact values('$contact_name','$contact_email','$ph','$msg','')";
        $mysqli->query($insert_query);

        $date=date("d/M/y");


        $to = "chippy@gmail.com";

        $subject = "ril - Enquiry from Contact ".$date;
        $headers .= 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= "From: abc@gmail.com" ;

        $to1 = $contact_email;
        $subject1 = "Raindrops Nursery - Enquiry from Contact ".$date;
        $headers1 .= 'MIME-Version: 1.0' . "\r\n";
        $headers1 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers1 .= "From: abc@gmail.com" ;

        $body1="<div class='msg'> <p>Dear ".$contact_name .",<br /><br />Thank you for your enquiry. It has been forwarded to the relevant department and<br /> will be dealt with as soon as possible.<br /><br />"."</p>"."</div>";

        $body="<table border='1'>"."<tr><td>Name</td><td>".$contact_name."</td></tr>"."<tr><td>Email</td><td>".$contact_email."</td></tr>"."<tr><td>Phone</td><td>".$ph."</td></tr>"."<tr><td>Message</td><td>".$msg."</td></tr></table>";

        mail($to, $subject, $body, $headers);
        mail($to1, $subject1, $body1, $headers1);

    } catch (Exception $ex) {    
        file_put_contents("log.txt","error found!".$ex.PHP_EOL,FILE_APPEND);
    }
    finally {

        echo "<script>window.location='thank-you.php'</script>";
    }
}

0 个答案:

没有答案