2

有什么办法可以将 HTML 代码放入电子邮件和自动回复消息中?当我尝试使用 HTML 代码输出电子邮件时。

   if ($_SERVER['REQUEST_METHOD'] == 'POST'){
  $mailto = 'info@website.com';
  $mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
  $subject = 'Email Subject';
  $message = 'Hello, Email message...'; // Want to try something like '<Strong>Hello</strong> Email message...'
  $success_url = './success.php';
  $error_url = './failed.php';
  $error = '';
  $autoresponder_from = 'noreply@website.com';
  $autoresponder_subject = 'Auto Response Subject';
  $autoresponder_message = 'Hello John, Thank you.'; // Want to try something like '<Strong>Hello John</strong> Thank you.'
4

1 回答 1

3

您需要为 html 电子邮件设置正确的标题

看看例子#4:http ://www.php.net/manual/en/function.mail.php

PHP

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

不要忘记添加您的消息的纯副本

于 2013-09-04T12:32:03.353 回答