2

我们最近升级到了 Plesk Parallel Linux 服务器,它看起来好像 PHP 设置忽略了标题!电子邮件接收良好,但显示HTML 标记。

phpInfo()文件可以在这里查看:https ://www.pressgofer.com/phpInfo.php

PHP 本身应该没问题,但无论如何都将它包含在此处。

PHP 邮件代码

$email = "example@example.com";
$message = "<h1 style='font-family:Helvetica,Arial;font-size:17px'>Your account has a password reset request</h1>";

$headers = "From: noreply@pressgofer.com \r\n";
$headers .= "Reply-To:  noreply@pressgofer.com \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

mail($email, "Reset password notification", $message, $headers);

非常感谢,尼克

4

2 回答 2

2

你的phpinfo节目mail.add_x_header是关闭的。你需要打开它

要启用X-Mail标头,mail.add_x_header请在您的php.ini

<?php
$to = "yourplace@somewhere.com";
$subject = "My HTML email test.";
$headers = "From: sinha.ksaurabh@gmail.com\r\n";
$headers .= "Reply-To: sinha.ksaurabh@gmail.com\r\n";
$headers .= "Return-Path: sinha.ksaurabh@gmail.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$message = "<html><body>";
$message .= "<h1> This is a test </h1>";
$message .= "</body></html>";

if ( mail($to,$subject,$message,$headers) ) {
   echo "The email has been sent!";
   } else {
   echo "The email has failed!";
   }
?> 
于 2013-03-21T10:49:31.627 回答
0

从 php 发送邮件:标题被解释为正文?

问题与 MIME 类型和服务器解释相关 -\r不需要。

于 2013-03-21T11:39:29.317 回答