联系我们邮件错误 [英] Contact us mail error

查看:92
本文介绍了联系我们邮件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的联系表单html页面及其以下的html代码是php代码

My html coding for the contact form html page and below that is the php code

<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文件

contact.php file

<?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>';
}
?>

以上是我的代码plz,因为我已经托管在网站上,所以可以帮助我解决问题可以在我的本地服务器上正常运行,但不能在网站上运行

Above is my code plz help me to overcome my problem since i have hosted in the site, it works well in my local server but not working in the website

推荐答案

您也有一个非常常见的错误,很多人都对与我们联系表格。

You also have a very common error a lot of people have with "Contact Us" forms.

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

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

This will break SPF and also cause DMARC to fail and you will never get the message from some people, if your mail server you use has DMARC enabled on it.

由于DMARC是较新的协议,因此许多与我们联系的旧的cookie切割器代码表格-并未考虑在内。

Since DMARC is a more recent protocol, a lot of the old cookie cutter code for contact us forms - doesn't take this into account.

您可以在此处了解更多信息: DMARC-联系表格噩梦

You can read more about that here: "DMARC - Contact Form Nightmare"

建议的解决方法是:

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

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

This way - you avoid the issue outline in the article. You won't quickly be able to hit the "Reply" button, but at least you'll get the emails from those customers who have DMARC enabled.

这篇关于联系我们邮件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆