从PHP mailer脚本向电子邮件正文中添加HTML
我正试图找到一种方法,通过我在以下网站上找到的现有AJAX PHP表单邮件器在电子邮件正文中包含HTML代码: 当我将自己的HTML代码添加到电子邮件正文中时,它只显示标记 这是来自的原始编码从PHP mailer脚本向电子邮件正文中添加HTML,php,html,css,ajax,email,Php,Html,Css,Ajax,Email,我正试图找到一种方法,通过我在以下网站上找到的现有AJAX PHP表单邮件器在电子邮件正文中包含HTML代码: 当我将自己的HTML代码添加到电子邮件正文中时,它只显示标记 这是来自的原始编码 修改标题 $headers = "From: " . strip_tags($_POST['req-email']) . "\r\n"; $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n"; $headers .= "CC:
修改标题
$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "CC: susan@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
然后在您的邮件中,包括普通HTML标记
<html>
<body>
Message
</body>
</html>
消息
你能试着用下面的例子,然后重新编写你的脚本吗?我正在发布的脚本就是我在项目中使用的脚本
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Adding html to php mail sender';
// message
$message = '
<html>
<head>
<title>html code with php</title>
</head>
<body>
<p>Here are the things to do</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>xyz</td><td>3rd</td><td>September</td><td>2017</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>';
// 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";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' .
"\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
$to='1!'aidan@example.com' . ', '; // 注意逗号
$to.='wez@example.com';
//主题
$subject='将html添加到php邮件发件人';
//信息
$message='1
用php编写html代码
下面是要做的事情
人月耳
2017年9月3日
萨勒17塔古斯特1973
';
//要发送HTML邮件,必须设置内容类型标题
$headers='MIME版本:1.0'。“\r\n”;
$headers.='内容类型:文本/html;字符集=iso-8859-1'。“\r\n”;
//附加标题
$headers.='To:Mary,Kelly'。
“\r\n”;
$headers.=“发件人:生日提醒”。“\r\n”;
$headers.='Cc:birthdayarchive@example.com' . “\r\n”;
//邮寄
邮件($to、$subject、$message、$headers);
实际上,您似乎(可能)借用了问题结束时使用的副本以及mail()函数的手册
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Adding html to php mail sender';
// message
$message = '
<html>
<head>
<title>html code with php</title>
</head>
<body>
<p>Here are the things to do</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>xyz</td><td>3rd</td><td>September</td><td>2017</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>';
// 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";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' .
"\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);