-1

我正在开发一个简单的网站,但在联系表单方面遇到了一些问题,我尝试了所有类型的设置,但它没有用。

问题是当我填写表格并按下提交按钮时,它会显示“消息发送成功”但我无法收到任何邮件到我的邮件 ID。

那我该怎么办……???

我的PHP CODE:文件名是“ mail.php

<?php
  echo '<html xmlns="http://www.w3.org/1999/xhtml">';
  echo '<head>';
  echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
  echo '<title>';
  echo $title;
  echo '</title>';
  echo '</head>';
  echo '<body>';  

$to = "anup.karanjkar08@gmail.com;
$subject = $_REQUEST['Name'] + "Sent a Mail";
$message = $_REQUEST['Message'] ;
$from = $_REQUEST['Email'] ;
$headers = "From:" . $from;
$a= mail($to,$subject,$message);
if ($a) {
  echo "Message sent successfully";
}
else
{
  echo "Sorry there is an error.";
}
echo '</body>';
echo '</html>';

?>

我的HTML CODE

<form name="contact_to_infrasure" id="infrasure"  action="mail.php" method="POST">
          <div class="row-fluid">
            NAME<br><input  type="text" name="Name">
          </div>
          <div class="row-fluid">
            EMAIL<br><input  type="text" name="Email"><br>
          </div>
          <div class="row-fluid">
            MESSAGE<br><textarea rows="5" style="width: 60%"  name="Message"></textarea><br>
          </div>
          <div class="row-fluid">
           <!--  <input class="span3" type="submit" value="SEND MESSAGE"> -->
          <button class="btn" type="submit" value="Submit" onClick="">SEND MESSAGE</button> 
          </div>
      </form>

请帮我...!!!

4

2 回答 2

4

首先在这一行添加结尾“。

$to = "anup.karanjkar08@gmail.com";

然后尝试运行,如果它有效。

请与托管服务提供商确认 php 中的邮件功能是否正常工作。

于 2013-11-14T08:07:03.160 回答
0

更改了这些行,php 中使用的连接.不是++在 javscript 中使用 $subject = $_REQUEST['Name'] . "Sent a Mail";

        <?php
          echo '<html xmlns="http://www.w3.org/1999/xhtml">';
          echo '<head>';
          echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
          echo '<title>';
          echo $title;
          echo '</title>';
          echo '</head>';
          echo '<body>';  

            $to = "anup.karanjkar08@gmail.com";
            $subject = $_REQUEST['Name'] . "Sent a Mail"; // changed this line  removed + 
            $message = $_REQUEST['Message'] ;
            $from = $_REQUEST['Email'] ;
            $headers = "From:" . $from;
            $a= mail($to,$subject,$message, $headers); // added headers here
            if ($a) {
              echo "Message sent successfully";
            }
            else
            {
              echo "Sorry there is an error.";
            }
            echo '</body>';
            echo '</html>';

        ?>

邮件发不出去的原因,

ISP 块

越来越多的 ISP 正在阻止端口 25,即用于发送电子邮件的端口。许多主要的 ISP,包括 NetZero、MSN、Earthlink、AT&T、Comcast 和 Verizon,都阻止了端口 25,以试图控制垃圾邮件。如果您的 ISP 阻止端口 25,那么您将无法从服务器发送电子邮件。这不是服务器问题,而是您的 ISP 直接阻止。我们通常可以通过将您的邮件服务器配置为侦听其他端口来解决这些问题。

参考:http ://www.rackaid.com/resources/cannot-send-email-how-to-fix-email-sending-and-receiving-errors/

于 2013-11-14T08:08:58.993 回答