Php 来自邮件头的邮件

Php 来自邮件头的邮件,php,Php,有人能指出为什么From:标题不起作用吗?相反,我收到了类似于myhost@conf.... <?php $send=$_POST['send']; if ($send){ $to="example@hotmail.com"; $subject=$_POST['subject']; $headers = 'From: webmaster@example.com'; $firstname=$_POST['firstname']; $body=$_POST['message']

有人能指出为什么From:标题不起作用吗?相反,我收到了类似于myhost@conf....

<?php


$send=$_POST['send'];

if ($send){


$to="example@hotmail.com";
$subject=$_POST['subject'];

$headers = 'From: webmaster@example.com';

$firstname=$_POST['firstname'];

$body=$_POST['message'];

$mailers_name=ucwords($firstname);

if (!mail($to,$subject,$body,$headers)) 
    {
        header("LOCATION: http://www.mysite.co.uk/success.php?none=not");

}else {

    header("LOCATION: http://www.mysite.co.uk/success.php?none=yes");

    }
}
?>

我想你最后需要
\r\n
在那里

$headers='来自:webmaster@example.com' . “\r\n”


$headers=“From:webmaster@example.com\r\n“

来自PHP手册中的用户说明,以下内容由以下人员发布:

我和他有过各种各样的问题 不设置“-f”的脚本 user@example.org“使用时的参数 mail(),如果postfix是sendmail 特工

在postfix中,我使用了SMTP中继 基于发送方的身份验证 地址,但它始终是PHP 用户作为发送者,直到我调整 代码来源:


致:



我认为,在邮件中设置附加标题时,不需要尾部CRLF。您的网络托管提供商是什么?您是否在指定的发件人地址中使用自己的域名?是的,我使用自己的域名
<?php mail('test@example.org', 'Subject', 'Body', 'From: user@example.org'); ?> 
<?php mail('test@example.org', 'Subject', 'Body', 'From: user@example.org', '-f user@example.org'); ?>