Heredoc没有正确显示HTML

时间:2016-04-27 09:37:00

标签: php html email

我仍然是PHP的绿色,我使用php构建了一个简单的mail()表单。我已尽力整理代码并使用提供的here语法和方法。

但是,我仍在使用EOD遇到一些问题。我已将EOD编码为发送一些基本的html行<br/> <hr/> <b/> <em/> etc.。我的问题是,邮件客户端(如mac mail,outlook等)无法识别HTML。

我尝试过简单地使用$body = '<html></html>';并根据php上的文档声明标头。但我仍然有同样的问题。我在下面列出了我的基本邮件功能;可能是某些语法错误或者我完全错过了其他内容。但是,经过一两天的故障排除后,我似乎无法隔离问题。

非常感谢任何帮助。

// mail body.
  $body = <<<EOD
<h2>Booking Request / $date</h2>
<hr/><br/>
Last Name: $lnameField<br/>
First Name: $fnameField<br/>
Company: $comField<br/>
Title: $ttlField<br/>
Email: $emaField<br/>
Acitivity: $actSelect<br/>
<br/>
<h2>Contact Info</h2>
<hr><br/>
Add Line 1: $add1Field<br/>
Add Line 2: $add2Field<br/>
Country: $couField<br/>
Telephone: $telField<br/>
<br/>
Requested Booking day:   $daySelect<br/>
Requested Booking Time:  $selectedTime<br/>
<br/>
Interested in: $selectedProjects.<br/>
Comments: $comms<br/>
submitted: <b>$date</b> at <b>$time</b>.
EOD;

// form submission check.
  if (isset($_POST['btn-sub'])) {

    // subject & account.
      $emailSub = 'Drupa 2016 - Booking Form Actioned';
      $emailAcc = 'MGI Technology (SHCP) <testing@test.co.uk>';

    // confirmation details.
      $confSub = 'Confirmation of booking';
      $conf_sender = 'MGI Technology (SHCP) <no-reply@test.co.uk>';

    // mail headers
      $headers   = array();
      $headers[] = "MIME-Version: 1.0";
      $headers[] = "Content-type: text/html; charset=iso-8859-1";
      $headers[] = "From: $conf_sender";
      $headers[] = "X-Mailer: PHP/".phpversion();

    // mail info
      $success = mail($emailAcc, $emailSub, $body, implode("\r\n", $headers));
      $confirm = mail($_POST['ema'], $confSub, $body, implode("\r\n", $headers));
  }

  // redirect & exit.
  header('Location: prox.php');
  exit();

0 个答案:

没有答案