0

我在 rackspace 服务器上设置了 centOs 6,并安装了 Apache PHP 和其他模块。我还安装了 sendmail 以使用 PHP 中的 mail() 函数,它可以工作,但我无法在 mail() 中设置自己的标题。

 $to = "myemail@gmail.com"; 
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";


 $from = " Team <my@odomain.com>"; 
 $headers  = "From: $from\r\n"; 
 $headers = "MIME-Version: 1.0\n" ;
 $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";

 if (mail($to, $subject, $body)) {
   echo("<p>Message successfully sent!</p>");
  } else {
   echo("<p>Message delivery failed...</p>");
  }

但是我收到了标题为“Apache apache@server”的垃圾邮件。标题未设置。我也试过“-f emailaddress”,但没有用。

我应该怎么办?我也尝试了一些 sendmail 配置,但仍然没有解决。

里特什

4

1 回答 1

0

在行中替换\r\n\n$headers = "From: $from\r\n";

于 2012-05-14T14:28:53.987 回答