【问题标题】:Contact us mail error联系我们邮件错误
【发布时间】:2013-05-14 09:28:24
【问题描述】:

我的联系表单html页面的html编码,下面是php代码

<form name="form1" method="post" action="contact.php" id="contactform">
                                <table width="100%" border="0" cellspacing="1" cellpadding="3">
                                    <tr>
                                        <td><input name="name" type="text" id="name" ONFOCUS="clearDefault(this)" value="Name" size="90" style="background: #DAEDFF; border:1px solid #DAEDFF; border-radius:3px; height: 25px;"></td>
                                    </tr>
                                    <tr>
                                        <td><input name="customer_mail" type="text" value="Email" ONFOCUS="clearDefault(this)" id="customer_mail" size="90" style="background: #DAEDFF; border:1px solid #DAEDFF; border-radius:3px; height: 25px;"></td>
                                    </tr>
                                    <tr>
                                        <td width="82%"><input name="subject" type="text" value="Subject" ONFOCUS="clearDefault(this)" id="subject" size="90" style="background: #DAEDFF; border:1px solid #DAEDFF; border-radius:3px; height: 25px;"></td>
                                    </tr>
                                    <tr>
                                        <td><textarea name="detail" cols="90" rows="8" id="detail" style="background: #DAEDFF; border:1px solid #DAEDFF; border-radius:3px;"></textarea></td>
                                    </tr>
                                    <tr>
                                        <td style="padding-left: 530px;"><input type="submit" name="Submit" value="Send" style="background: #1B99E8; border: 1px solid #1B99E8; color: #ffffff; border-radius:3px;"></td>
                                    </tr>
                            </table>
                        </form>

contact.php 文件

<?php

$subject        =   $_POST['subject'];
$detail         =   $_POST['detail'];
$customer_mail  =   $_POST['customer_mail'];
$name           =   $_POST['name'];

// Contact subject
$subject ="$subject"; 

// Details
$message="$detail";

// Mail of sender
$mail_from="$customer_mail"; 

// From 
$header="from: $name <$mail_from>";

// Enter your email address
$to ='it@reverseinformatics.com';
$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email 
// display message "We've recived your information"
if($send_contact){
echo '<script language="javascript">confirm("We have received your request, our team will contact you shortly.")</script>';
echo '<script language="javascript">window.location = "contact.html"</script>';
}
else {
echo '<script language="javascript">confirm("Oops Sorry for the inconvinience.")</script>';
echo '<script language="javascript">window.location = "contact.html"</script>';
}
?>

以上是我的代码,请帮助我克服我的问题,因为我已经在网站上托管,它在我的本地服务器上运行良好,但在网站上无法运行

【问题讨论】:

  • 我们无法读懂您的想法,请发布您的代码。
  • 如果没有看到产生错误的代码,谁也帮不上忙
  • 确保 sendmail 在您的主机上正常工作。
  • 不,实际上点击发送按钮时它并没有连接到我的 php 文件本身。

标签: php contact-form


【解决方案1】:

我猜你在 window.location = "contact.html" 部分的代码有问题。 如果您想重定向到此页面,请尝试提供绝对路径。 您也可以尝试 window.location.hrefwindow.open。 请注意,window.open 会在新窗口中打开它。

【讨论】:

  • 如果点击“发送”时它没有连接到您的 php 文件,请确保contact.php 确实在同一个文件夹中。
  • s 我将 dat contact.php 文件保存在文件夹中,但也没有使用同样的问题,“系统找不到指定的路径。”
  • 点击发送时会重定向到contact.php页面,但显示为系统找不到指定的路径。'
  • 奇怪...我希望文件名没有拼写错误...您使用的是 HTML4 还是 HTML5?尝试在表单操作中给出像“example.com/example.php”这样的绝对路径
  • 是在托管服务器中运行的文件夹中仅在 java 邮件中执行 jsp 和 java 文件的任何方式
【解决方案2】:

您还有一个很多人在使用“联系我们”表单时遇到的非常常见的错误。

// Mail of sender
$mail_from="$customer_mail"; 

这将破坏 SPF 并导致 DMARC 失败,如果您使用的邮件服务器启用了 DMARC,您将永远不会收到某些人的邮件。

由于 DMARC 是较新的协议,许多用于联系我们表单的旧的千篇一律的代码 - 没有考虑到这一点。

您可以在此处阅读更多相关信息:"DMARC - Contact Form Nightmare"

建议的解决方法是:

$mail_from='it@reverseinformatics.com';
$subject ="$subject" .  $_POST['customer_mail']; 

这样 - 您可以避免文章中的问题概述。您将无法快速点击“回复”按钮,但至少您会收到那些启用了 DMARC 的客户的电子邮件。

【讨论】:

    猜你喜欢
    • 2012-11-15
    • 2013-02-11
    • 1970-01-01
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 2018-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多