联系表格问题,每次都无法发送邮件

时间:2012-08-19 19:24:58

标签: php

我正在为我的wordpress网站制作联系表格,wordpress目前托管在我的本地服务器上,位于xampp上。我的问题是表单工作偶尔,但有时我检查发送邮件日志抛出错误信息,它显示不同的错误,如连接超时,套接字错误#10060Connection timed out.etc

以下是我的代码

<?php


   if(isset($_POST['submit']))
  {
    $to = "my@gmail.com";
    $subject = "contact form";
    $message =  $_POST['comments'].$_POST['telephone'];
    $headers =  $_POST['email'];

     mail($to,$subject,$message,$headers) or die('failure');
     echo "message has been successfully sent" ;

   ?>
   <?php } else { ?>



    </div>
   <div  style = "margin-top:280px;" id="formcontainer">
   <form name="htmlform" method="post" action="<?php the_permalink(); ?>">
   <table width="550px">
    </tr>

   <tr>
   <td valign= "top">
   <label  for="first_name">Full Name</label>
  </td>
  <td valign= "top">
  <input style = "height:20px; width:400px" type="text" name="first_name" maxlength="50"     size="50">
  </td> 
</tr></br>



   <!--<tr>
  <td valign="top"">
   <label for="last_name">Last Name *</label>
  </td>

  <td valign="top">
   <input style = "height:20px;width:400px" type="text" name="last_name" maxlength="50"     size="50">
 </td>
</tr> -->
<tr>
 <td valign="top">
  <label for="email">Email Address </label>
 </td> 
 <td valign="top">
  <input style = "height:20px; width:400px" type="text" name="email" maxlength="80" size="50">
 </td>

</tr></br>
<tr>
 <td valign="top">
  <label for="telephone">Telephone Number</label>
 </td>
 <td valign="top">
  <input style = "height:20px;width:400px"  type="text" name="telephone" maxlength="30" size="50">
 </td>
</tr></br/>

<tr valign="middle">
 <td valign="middle">
  <label style = " vertical-align:middle;"for="comments">Message</label>
 </td>
 <td valign="top">
  <textarea style = "height:200px;width:400px"  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
 </td>

</tr>
<tr>
 <td colspan="2" style="text-align:center">
       <input type="submit" name="submit" value="Send" />


  <!--<input type="submit" value="1"> -->
 </td>
</tr>
</table>
</form>
</div>

<?php } ?>

0 个答案:

没有答案