dpr81047 2015-09-08 04:41
浏览 25
已采纳

PHP邮件功能不起作用[重复]

This question already has an answer here:

I'm currently working on a web portfolio site for one of my web design courses, and it will hopefully become my actual portfolio when finished. Part of the assignment requires a "contact me" section for the site, which would include a form that validates input data and redirects the user on a proper submission. I have this finished, but I want it to actually email me when some submits the form. Here is my code:

$admin_mail = example@mail.com
-code to validate form-
$headers = array("First Name: " => $_POST['first_name'],
                        "Last Name: " => $_POST['last_name'],
                        "Email: " => $_POST['email'],
                        "Company: " => $_POST['company']);
$message = wordwrap($_POST['message'],70);
mail($admin_mail,"Portfolio Message",$message,$headers);
header("location: success.html");

I checked both the $headers and $message variables with the print_r function, and they're working properly. All of the entered data is being added and the page redirects correctly, but the email doesn't appear to send at all. I checked that my webhost can send and receive emails, and that appears to work correctly as well.

Any ideas on how to fix this?

</div>
  • 写回答

4条回答 默认 最新

  • dongti8535 2015-09-08 04:51
    关注

    just check..by imputing the real email Id

    <?php
    $to = "somebody@example.com";
    $subject = "My subject";
    $txt = "Hello world!";
    $headers = "From: webmaster@example.com" . "
    " .
    "CC: somebodyelse@example.com";
    
    mail($to,$subject,$txt,$headers);
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?