douling8087 2013-01-24 16:50
浏览 13

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!

  • 写回答

1条回答 默认 最新

  • du4010 2013-01-24 17:19
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100