PHP:getallheaders()无法在mail()中工作?

I am trying to do something like:

<?php
// Defining function getallheaders() as it is disabled on my host
    function getallheaders() 
    { 
           $headers = ''; 
       foreach ($_SERVER as $name => $value) 
       { 
           if (substr($name, 0, 5) == 'HTTP_') 
           { 
               $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; 
           } 
       } 
       return $headers;
}

$getheader=getallheaders();

mail("me@domain.com","mail","Headers: 
 $getheader");
?>

It sends me a mail like:

Headers: Array( 

Why doesn't it mail all the headers? Thx in advance :)

You created $heareds variable as an array.

Instead of:

$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;

Use this:

$headers .= str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5))))) .': ' . $value . "
";