PHP邮件功能发送电子邮件,但不发送html表单数据

时间:2018-04-10 16:52:20

标签: php html email web

HTML包含下面php中列出的简单输入字段,PHP mail()发送电子邮件但不包括表单数据本身。我花了很多时间但不确定为什么会这样。

和php发送邮件:

<?php

$to = "user@gmail.com";
$subject = "Question Bank - New Question";
$message = '<html>
        <head>
          <title>New Question</title>
          <style>
            table {
                         border: 1px solid black;
                       }
            table th, tr{
                text-align:center;
            }
          </style>

        </head>
        <body>
          <table cellspacing="20px">
            <tr>
              <th>Username</th>
              <th>Email</th>
              <th>Question</th>
              <th>Question Hint</th>
              <th>Correct Answer</th>
            </tr>
            <tr>
              <td>'.$_POST["username"].'</td>
              <td>'.$_POST["email"].'</td>
              <td>'.$_POST["question"].'</td>
              <td>'.$_POST["questionhint"].'</td>
              <td>'.$_POST["answer"].'</td>
            </tr>
          </table>
        </body>
        </html>';

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";


$headers .= 'From:  user@company.com' . "\r\n";
$headers .= 'Cc: cc@example.com' . "\r\n";

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

0 个答案:

没有答案