PHP mail() Not displaying HTML


PHP mail() Not displaying HTML

我们最近升级到Plesk并行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);

很多谢谢,尼克

您的phpinfo显示mail.add_x_header是OFF。你需要把它打开

要启用X-Mail头,在php.ini

中将mail.add_x_header设置为1
<?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!";
   }
?> 

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

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