2
function sendEmail($address,$subject,$message)
{
    $headers = "Reply-To: miloAds Team <admin@miloads.com>\r";
    $headers .= "Return-Path: miloAds Team <admin@miloads.com>\r";
    $headers .= "From: miloAds Team <admin@miloads.com>\r"; 
    $headers .= "Organization: Milonas Media LLC\r";
    $headers .= "MIME-Version: 1.0\r";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\r";
    $headers .= "X-Priority: 3\r";
    $headers .= "X-Mailer: PHP". phpversion() ."\r";

    mail($address, $subject, $message, $headers); 
}

发送电子邮件时,标题出现在正文中。

4

2 回答 2

1

尝试将每个\r转义更改为\r\n,看看是否有帮助。

Quoth PHP手册

附加标题(可选)

String to be inserted at the end of the email header.

This is typically used to add extra headers (From, Cc, and Bcc).
Multiple extra headers should be separated with a CRLF (\r\n).

确保也不包括最后一个标题的尾随\r\n

还要确保从 中删除任何换行符,$subject因为这可能会导致问题。看看这些是否有帮助。

于 2012-04-30T23:03:38.217 回答
0

添加\n\r, 即\r\n并删除最后一个:

function sendEmail($address,$subject,$message)
{
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
    $headers .= "From: miloAds Team <admin@miloads.com>\r\n"; 
    $headers .= "Reply-To: miloAds Team <admin@miloads.com>\r\n";
    $headers .= "Organization: Milonas Media LLC\r\n";
    $headers .= "X-Priority: 3\r\n";
    $headers .= "X-Mailer: PHP". phpversion();

    mail($address, $subject, $message, $headers); 
}
于 2012-04-30T23:03:20.210 回答