我在我的 Ubuntu 服务器上设置了 PHP 和 Postfix。我需要从 PHP 脚本发送 HTML 电子邮件。电子邮件发送得很好,但它显示为包含 HTML 标签的纯文本。此外,一些标题也显示在电子邮件本身中。
我的猜测是,它与标题有关。我花了将近一天的时间寻找可能的解决方案,但还没有找到。
下面是 PHP 代码:
$headers='';
$headers.="MIME-Version: 1.0 \r\n";
$headers.="Content-type: text/html; cht=\"UTF-8\" \r\n";
$headers.="From: ".FROM_EMAIL."\r\n";
mail($email, $vars['title'], $content, $headers);
编辑:
$headers='';
$headers.='MIME-Version: 1.0'."\r\n";
$headers.='Content-type: text/html; cht=iso-8859-1'."\r\n";
$headers.='From: Kinesioteip.ee<'.FROM_EMAIL.'>'."\r\n";
$headers.='To: '.$email."\r\n";
mail($email, $vars['title'], $content, $headers);
仍然没有运气...
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; cht=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To:' . "\r\n";
$headers .= 'From: Admin<youremail@email.com>' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
你能试着改变这些线条吗
$headers.="MIME-Version: 1.0 \r\n";
$headers.="Content-type: text/html; cht=\"UTF-8\" \r\n";
到
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; cht=iso-8859-1' . "\r\n";
看看他们是否工作
我认为你的第四个标题是错误的,因为 FROM_EMAIL 变量没有 '$'
尝试
$headers.="From: ".$FROM_EMAIL."\r\n";
$vars ['title'] 更改为 $var
mail($email, $vars, $content, $headers);
本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处
评论列表(20条)