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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?