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

时间:2013-01-24 16:50:49

标签: html forms php

代码:

<?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' . "\r\n" .
    'Reply-To: xxx@xxx.com' . "\r\n" .
    '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' . "\r\n";
$header2 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$header2 .= 'From: no-reply@xxx.com' . "\r\n";
$header2 .= 'Reply-To: xxx@xxx.com' . "\r\n";
$header2 .= 'X-Mailer: PHP Version: 5.0+' . "\r\n";

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

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

?>

不发送电子邮件,而且过去常常发送电子邮件。我想知道改变了什么?也许托管公司更新了php或者我不知道的东西?我真的迷路了。也许我只是忽略了一些东西,也许是语法。我希望你们都能帮忙!提前谢谢!

1 个答案:

答案 0 :(得分:0)

我尝试了从表单修改数据的代码,但它确实有效。错误不会出现您怀疑

的语法

我的猜测是:您的 sendmail 要么已损坏,要么路径错误(/ usr / sbin / sendmail)。如果您在自己的服务器上工作,请使用

检查您的sendmail路径
  

phpinfo()函数

如果它是托管服务(我理解这是您的情况),请联系支持部门,因为这是服务器问题。

如果您拥有对此类托管服务的ssh访问权限,请访问它并使用以下命令执行您的脚本:

php -q *[yourScript.php]*

与错误报告一起,它可以让您跟踪bin文件发生的事情