【问题标题】:Table is not creating in mail body表未在邮件正文中创建
【发布时间】:2017-06-10 03:23:18
【问题描述】:

我正在尝试以表格形式将用户输入发送到邮件,用户输入正在传递到邮件,但我无法在那里创建表。到目前为止,我所做的是:

HTML

<input type="text" class="form-control fc" name="patient" id="Patient">
<input type="date" class="form-control fc" name = "date" id="Date">
<input type="text" class="form-control fc" name = "Assistant" id="Assistant">

PHP部分

if(isset($_POST['submit'])) {

$email_to = "xyz@gmail.com";
$email_subject = "Data";
$patient = $_POST['patient'];
$date = $_POST['date'];
$Assistant = $_POST['Assistant'];


$email_message ="<html><body>";
$email_message .= "<table><tr><td>Field Name : </td><td>Value</td></tr>";
$email_message .= "<tr><td>Patient Name : </td><td>".$patient."</td></tr>";
$email_message .= "<tr><td>Date:</td><td> ".$date."</td></tr>";
$email_message .= "<tr><td>Assistant:</td><td> ".$Assistant."</td></tr></table>";
$email_message .="</body></html>";


// create email headers
$headers = 'From: '.xyz@gmail.com."\r\n".
'Reply-To: '.xyz@gmail.com."\r\n" .
'' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); ?>

【问题讨论】:

    标签: php html-table html-email


    【解决方案1】:

    要发送 html 邮件,您必须设置标题:

    $headers[] = 'MIME-Version: 1.0';
    $headers[] = 'Content-type: text/html; charset=iso-8859-1';
    

    查看手册页:http://php.net/manual/en/function.mail.php

    【讨论】:

      【解决方案2】:

      使用 PHPMailer https://github.com/PHPMailer/PHPMailer.

      $mailer = new PHPMailer();
      $mailer->isHTML(TRUE);
      $mailer->Host = 'smtp host';
      $mailer->Port = 'smtp post';
      ....
      $mailer->body = "put your html here"
      $mailer->send();
      

      【讨论】:

        猜你喜欢
        • 2013-12-22
        • 2015-04-24
        • 2011-02-04
        • 1970-01-01
        • 1970-01-01
        • 2018-12-18
        • 1970-01-01
        • 2010-11-20
        • 1970-01-01
        相关资源
        最近更新 更多