php xmailer的问题? 我不认为这是语法

code:

<?php

session_start();
$name = htmlspecialchars($_POST['name']);
$phone = htmlspecialchars($_POST['phone']);
$email = htmlspecialchars($_POST['email']);
$staddress = htmlspecialchars($_POST['staddress']);
$city = htmlspecialchars($_POST['city']);
$state = htmlspecialchars($_POST['state']);
$zipcode = htmlspecialchars($_POST['zipcode']);
$eventtype = htmlspecialchars($_POST['eventtype']);
$guests = htmlspecialchars($_POST['guests']);
$month = htmlspecialchars($_POST['month']);
$day = htmlspecialchars($_POST['day']);
$year = htmlspecialchars($_POST['year']);
$hourstart = htmlspecialchars($_POST['hourstart']);
$hourfinish = htmlspecialchars($_POST['hourfinish']);
$eventstreet = htmlspecialchars($_POST['eventstreet']);
$eventcity = htmlspecialchars($_POST['eventcity']);
$eventstate = htmlspecialchars($_POST['eventstate']);
$eventzip = htmlspecialchars($_POST['eventzip']);
$howwereu = htmlspecialchars($_POST['howwereu']);
$custmsg = htmlspecialchars($_POST['custmsg']);
$date = date('m-d-Y');


$to = '' . $email . '';
$subject = 'Thanks,' .$name . ' for requesting a quote!';
$message = "We will contact you as soon as possible!  ";
$headers = 'From: no-reply@xxx.com' . "
" .
    'Reply-To: xxx@xxx.com' . "
" .
    'X-Mailer: PHP/' . phpversion();

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

$to2 = 'xxx@xxx.com';
$subject2 = '' . $name . ' has requested a quote!';
$message2 = '

<html>
<head>
<title>Contact Email</title>
</head>
<body>
<p>Here is the information provided. If the field is blank, the customer did not fill out the 
form.</p>
 <table>
<tr>
<td>Customer Name:</td>
<td>' . $name . '</td>
</tr>
<tr>
<td>Customer Email:</td>
<td>' . $email . '</td>
</tr>
<tr>
<td>Customer Phone:</td>
<td>' . $phone . '</td>
</tr>
<tr>
<td>Customer Street Address:</td>
<td>' . $staddress . '</td>
</tr>

<tr>
<td>Customer City:</td>
<td>' . $city . '</td>
</tr>
<tr>
<td>Customer State:</td>
<td>' . $state . '</td>
</tr>
<tr>
<td>Customer Zipcode:</td>
<td>' . $zipcode . '</td>
</tr>
<tr>
<td>Event Type:</td>
<td>' . $eventtype . '</td>
</tr>

<tr>
<td># of Guests:</td>
<td>' . $guests . '</td>
</tr>
<tr>
<td>Event Month:</td>
<td>' . $month . '</td>
</tr>
<tr>
<td>Event Day:</td>
<td>' . $day . '</td>
</tr>
<tr>
<td>Event Year:</td>
<td>' . $year . '</td>
</tr>

<tr>
<td>Event Start Hour:</td>
<td>' . $hourstart . '</td>
</tr>
<tr>
<td>Event Finish Hour:</td>
<td>' . $hourfinish . '</td>
</tr>
<tr>
<td>Event Street:</td>
<td>' . $eventstreet . '</td>
</tr>
<tr>
<td>Event City:</td>
<td>' . $eventcity . '</td>
</tr>
<tr>
<td>Event State:</td>
<td>' . $eventstate . '</td>
</tr>

<tr>
<td>Event Zip:</td>
<td>' . $eventzip . '</td>
</tr>
<tr>
<td>How were you referred:</td>
<td>' . $howwereu . '</td>
</tr>
<tr>
<td>Customer Message:</td>
<td>' . $custmsg . '</td>
</tr>
</table>
</body>
</html>

';
$header2  = 'MIME-Version: 1.0' . "
";
$header2 .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$header2 .= 'From: no-reply@xxx.com' . "
";
$header2 .= 'Reply-To: xxx@xxx.com' . "
";
$header2 .= 'X-Mailer: PHP Version: 5.0+' . "
";

mail($to2, $subject2, $message2, $header2);

header('Location: http://www.xxxx.com');

?>

Does not send emails, and it used to. I'm wondering what changed? Maybe the hosting company updated php or something without me knowing? I'm really lost. Maybe I've just overlooked something, maybe syntax. I hope you all can help! Thanks in advance!

I tried your code modifying the data from forms and it works. The error does not come from syntax as you suspected

My guess would be : your sendmail is either broken or a wrong path (/usr/sbin/sendmail). If you are working in your own server check your sendmail path using

phpinfo()

And if it's a hosting service (I understand this is your case) then contact support, since this is a server issue.

If you have ssh acces to such hosting service, access it and execute your script using:

php -q *[yourScript.php]*

Together with the error reporting and it may give you a trace to what's happening with the bin files