Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wordpress wp_mail正在以文本附件的形式发送我的html邮件_Wordpress - Fatal编程技术网

wordpress wp_mail正在以文本附件的形式发送我的html邮件

wordpress wp_mail正在以文本附件的形式发送我的html邮件,wordpress,Wordpress,这是发送邮件的代码: $to = $_POST['leadEmail']; $subject = "my subject"; $message = ( $_POST['leadEmailPref'] == "html" ) ? $messageh : $messagep ; $headers[] = "From: My Name <ny_name@gmail.com>"; $headers[] = "Content-type: ".$_POST['leadEmailPref'] ;

这是发送邮件的代码:

$to = $_POST['leadEmail'];
$subject = "my subject";
$message = ( $_POST['leadEmailPref'] == "html" ) ? $messageh : $messagep ;
$headers[] = "From: My Name <ny_name@gmail.com>";
$headers[] = "Content-type: ".$_POST['leadEmailPref'] ;

wp_mail( $to, $subject, $message, $headers );
$to=$\u POST['leadmail'];
$subject=“我的主题”;
$message=($_POST['leadmailpref']==“html”)$messageh:$messagep;
$headers[]=“发件人:我的姓名”;
$headers[]=“内容类型:”.$\u POST['leadEmailPref'];
wp_邮件($to、$subject、$message、$headers);

当我进入收件箱时,邮件将作为附件发送,我看不到邮件。显然,我不想要附件,我希望收到电子邮件的人立即看到邮件。

您的
内容类型:
是错误的。它应该是
text/html
text/plain
,而不是
html

$headers[]=“内容类型:text/”$\u POST['leadEmailPref']

您应该尝试:

add_filter( 'wp_mail_content_type', 'set_html_content_type' );

wp_mail( 'To Email', 'Subject', '<h1>Html Email</h1>' );

function set_html_content_type() {
    return 'text/html';
}

remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
add_filter('wp_mail_content_type','set_html_content_type');
wp_邮件('To Email','Subject','Html Email');
函数集\ html \内容\类型(){
返回“text/html”;
}
删除过滤器(“wp邮件内容类型”、“设置html内容类型”);

你为什么不转义$U POST['leadEmailPref']?人们可以插入额外的电子邮件标题我如何可以附加一个动态数据表到电子邮件内容?