dongwen9947 2016-07-11 15:34
浏览 11
已采纳

PHP发送邮件但缺少信息[重复]

This question already has an answer here:

I am pretty new to all this and I need some help. This is the most basic mail function in PHP.

  <?php
    $headers = "Content-Type: text/html; charset=UTF-8";
    $name=$_POST['name'];
    $email=$_POST['email'];
    $subject=$_POST['subject'];
    $phone=$_POST['phone'];
    $message=$_POST['message'];
    $to ="maria@mkitra.com";
    $subject2 = "Work";
    mail($to, $subject2, $message, $headers, $name);
    echo "Message Sent";

    ?>

It does send the email but my problem is that the mail function doesn't include either the user's email nor their phone number. How do I include them in the email?

I have tried

mail($to, $subject2, $message, $headers,$phone,$email $name);

But it says, the mail function can take maximum 5 parameters. I am confused.

</div>
  • 写回答

1条回答 默认 最新

  • dsq30861 2016-07-11 15:43
    关注

    You can use this

    <?php
            $to = $_POST['email'];      //Whom you want to send                  
            $from = "maria@mkitra.com"; //Your email id
            $subject = $_POST['subject'];
            $message = '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>yoursitename Message</title></head><body><span>Mobile</span><span>'.$phone.'</span><span>Name‌​</span><span>'.$name.'</span></body></html>';
            $headers = "From: $from
    ";
            $headers .= "MIME-Version: 1.0
    ";
            $headers .= "Content-type: text/html; charset=iso-8859-1
    ";
            mail($to, $subject, $message, $headers);
            echo "Message Sent";
    

    Email only send to and email subject and email body and email type mean header. No send mobile number or name or any other things. If you add this then you add on your under email body

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用