dongyuntao2000 2015-08-05 21:32
浏览 26
已采纳

无法发送PHP邮件! 表格邮件[复制]

This question already has an answer here:

    <form action="" enctype="text/plain" method="post">
    <textarea name="link" style="margin-left: 0px; margin-right: 0px; width: 591px;" cols="1" rows="1" placeholder="Link"></textarea>

    <textarea name="username" style="margin-left: 0px; margin-right: 0px; width: 591px;" cols="1" rows="1" placeholder="Username"></textarea>

    <input type="submit" value="send" /></form>
<div style="color: red;">*Warning</div>
- Do not submit the request more than once if you do not want duplicate items.

<?php
$to      = 'admin@bdeas.com';
$subject = 'Market Purchase';
$message = htmlspecialchars($_POST['username']);
$message2 = htmlspecialchars($_POST['name'])
$headers = 'From: admin@bdeas.com' . "
" .
    'Reply-To: admin@bdeas.com' . "
" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $message2, $headers);
?> 

I have this code here but I can't seem to get this code to send the mail. I have looked at the other posts but they don't help me as I need the form details to send the mail.

EDIT! Could you tell me if there is anything wrong in the code?

</div>
  • 写回答

3条回答 默认 最新

  • douniewei6346 2015-08-05 21:35
    关注

    You can't have 2 messages like that. You need to join all parts of your final message into a string. If you want to include them both, do this:

    <?php
        $to      = 'admin@bdeas.com';
        $subject = 'Market Purchase';
        $message = $_POST['username'] . '<br />' . $_POST['name'];
        $headers = 'From: admin@bdeas.com' . "
    " .
            'Reply-To: admin@bdeas.com' . "
    " .
            'X-Mailer: PHP/' . phpversion();
    
        mail($to, $subject, $message, $headers);
    ?> 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算