Php html电子邮件文本区域中的wp_邮件换行符
我在使用wp_邮件功能时遇到问题,希望有人能帮助我 我需要在用户添加到文本区域“message”的电子邮件中插入换行符 有人能帮忙吗 我目前通过联系人表单发送电子邮件的代码如下:Php html电子邮件文本区域中的wp_邮件换行符,php,html,wordpress,email,Php,Html,Wordpress,Email,我在使用wp_邮件功能时遇到问题,希望有人能帮助我 我需要在用户添加到文本区域“message”的电子邮件中插入换行符 有人能帮忙吗 我目前通过联系人表单发送电子邮件的代码如下: <?php if( !isset($_REQUEST) ) return; require('../../../../wp-load.php'); function wpse27856_set_content_type(){ return "text/html"; } add_filter( 'wp_mail
<?php
if( !isset($_REQUEST) ) return;
require('../../../../wp-load.php');
function wpse27856_set_content_type(){
return "text/html";
}
add_filter( 'wp_mail_content_type','wpse27856_set_content_type' );
$name = $_REQUEST['name'];
$phone = $_REQUEST['phone'];
$email = $_REQUEST['email'];
$msg = $_REQUEST['message'];
$headers = 'From: '.$name.' <'.$email.'>' . "\r\n";
$message = '
<html>
<body>
Someone has made an enquiry on the online contact form:
<br /><br />
<b>Contact Details:</b><br />
'.$name.'<br />
'.$phone.'<br />
'.$email.'<br /><br />
<b>Message:</b><br />
'.$msg.'<br />
<br /><br />
</body>
</html>
';
wp_mail('email@email.co.uk', 'Contact form Message' , $message, $headers);
?>
如果您的文本区域包含html,您可以将标题添加到邮件中
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$msg=nl2br($_请求['message'])代码>默认情况下,wp_mail()以纯文本形式发送消息,因此电子邮件客户端不会解析HTML
在电子邮件中包含以下标题:
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
因为您的电子邮件是HTML格式的,所以最好使用适当的HTML模板(HTML、头、体…)使其有效
或者,您可以使用回车符(\r\n)替换
标记,尽管您仍然需要删除标记
这已经包含在PHP mail()文档中,wp_mail()围绕该文档展开
使用此标题在电子邮件中发送html
$headers = "MIME-Version: 1.0" . "\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\n";
$headers .= "X-Priority: 1 (Higuest)\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "Importance: High\n";
$headers .= "From: Approprice <".$mailfrom.">" . "\n";
$headers .= "Return-Path: Approprice <".$mailfrom.">" . "\n";
$headers .= "Reply-To: Approprice <".$mailfrom.">";
$headers=“MIME版本:1.0”。“\n”;
$headers.=“内容类型:text/html;字符集=iso-8859-1”。“\n”;
$headers.=“X优先级:1(最高)\n”;
$headers.=“X-MSMail-Priority:高\n”;
$headers.=“重要性:高\n”;
$headers.=“发件人:价格”。“\n”;
$headers.=“返回路径:价格”。“\n”;
$headers.=“回复:价格”;
谢谢。为我工作。