0

我使用 php、html 和 css 编写了一个代码。这是提交后通过电子邮件收到的联系表格。提交时没有错误,但我没有收到电子邮件。我在这里包括代码。这是链接:http ://complaintdesk.byethost15.com/contact.php 。我也在这里包含代码。

联系人.php

<?php
if(isset($_POST['submit'])){
    $name = $_POST['fullname'];
    $branch = $_POST['branch'];
    $usn = $_POST['usn'];
    $sem = $_POST['sem'];
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $description = $_POST['comment'];

    $to = 'email@example.com';

    $display = 'From:</br>Name: $name</br>USN: $usn</br>Branch: $branch</br>Semester: $sem</br>Email: $email</br></br>$description';
    mail($to,$subject,$display);
    echo "<script>alert('Your Complaint has been succesfully submitted, We will contact you soon.')</script>";
};

?>

其余代码我不包括在内...

4

1 回答 1

0

尝试这个:

$to_address = "Your email address";
$subject = $_POST['subject'];
$headers = "MIME-Version: 1.0\r\n";
$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers.= "From: ".$email."\r\n";

if (mail($to_address,$subject,$description,$headers)){
    echo "Success";
}
else{
    echo "<h2>Unable to submit the form, please recheck the details.</h2>" ;
 }

更新:如果这不起作用,那么您的电子邮件配置可能有错误。正如上面评论中的其他用户所建议的那样,您可能也想查看该部分。此答案基于您的电子邮件服务器/PHP 配置正确的假设。

于 2013-07-22T17:24:29.153 回答