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条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘