php mail()主题一直显示为Apache Server

时间:2014-02-12 11:53:11

标签: php apache2

我正试图掌握php mail()函数。每当我发送邮件时,它都会一直显示在主题“Apache Server”中,而不是我在代码中指定的地址。我也改变了php.ini中的sendmail_from,重新启动了服务器,但仍然是相同的主题行。如何更改此选项以显示代码中指定的电子邮件地址。这是一个FQDN。

sendmail_from   admin@mydomain.co.uk
sendmail_path   /usr/sbin/sendmail -t -i


    $id = $_SESSION['kt_name_usr'];
    $to = "example@somewhere.com";
    $subject = "New Request.";
    $headers = "From: admin@mydomain.com\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    $body = "<html><body><b>testing system for requests not a real request</b></body></html>";
    $body .= $id;
    mail($to,$subject,$body,$header);

1 个答案:

答案 0 :(得分:1)

在您的代码中,您使用mail()函数中的变量$header。但实际上变量名是$headers。编辑如下:

mail($to,$subject,$body,$headers);