You could do this (replace the first line in your script with this)
$payload = file_get_contents('php://input');
$jsonArray = json_decode($payload);
$payload = "";
foreach($jsonArray as $key => $value){
$payload .= $key . ": " . $value . "
";
}
That should make payload a pretty string.
To add the serial number to the email subject, all you'd need to do is
...
'Subject' => "Server Info " . $jsonArray['SERIAL'],
...
Or you could just do
$payload = file_get_contents('php://input');
$payload = print_r($payload, true);