我们最近升级到了Plesk Parallel Linux Server,看起来好像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);
非常感谢, 尼克
答案 0 :(得分:2)
您的phpinfo
显示mail.add_x_header
已关闭。你需要打开它
要启用X-Mail
标头,请在mail.add_x_header
php.ini
设为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!";
}
?>
答案 1 :(得分:0)
sending mail from php: headers are interpreted as body?
问题与MIME类型和服务器解释相关 - 不需要\r
。