为什么PHP邮件不发送给多个收件人?

When using PHP's mail() function, I receive the email to both accounts when the "to" parameter is set to:

"test@example2.com,test@example1.com"

but when I swap them round:

"test@example1.com,test@example2.com"

the email is delivered to test@example2.com but not test@example1.com. Nor does it receive the email if is specified as the CC or BCC header.

Can anybody suggest why this may be the case? It was working fine up until a couple of weeks ago. As far as I am aware nothing has changed on my server, though it's shared hosting so it's possible that it has.

Things to note: The mail() function always returns true, regardless of order. example1.com is also the sending server.

My code is as follows:

$from = 'sales@example1.com';

$headers = '';
$headers .= 'From: My Site <' . $from . ">
" .
            'Reply-To: ' . $_POST["Email"] . "
" .
            'X-Mailer: PHP/' . phpversion();

$body = 'Message goes here';

$to = 'test@example1.com,test@example2.com'; // will not send to test@example2.com, though will if the addresses are swapped

if ( mail( $to, 'Subject goes here', $body, $headers, '-f ' . $from ) ) {
    $url = "/contact/?message=sent";
} else {
    $url = "/contact/?message=failed";
}

header("Location: $url");

Looking at the PHP Manual, I notice the example has a space after the comma.. Try

$to = 'test@example1.com, test@example2.com'; 

You could also use your headers section to add a CC

$headers .= 'Cc: 2ndaddress@example.com' . "
";