我的网站上有一个 PHP 电子邮件脚本,潜在客户可以用来联系我。从 Stack 得到它并稍微调整了一下(有一个蜜罐)。
PHP代码
<?php
$robotest = $_POST['robotest']; //just testin' for robots
$recipient = "info@agoodman.com.au"; //recipient
$email = ($_POST['email']); //senders e-mail adress
if((filter_var($email, FILTER_VALIDATE_EMAIL)) && ($robotest == "")) {
$Name = ($_POST['name']); //senders name
$mail_body = ($_POST['comments']); //mail body
$subject = "Image Consulting Inquiry"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
mail($recipient, $subject, $mail_body, $header); //mail command :)
} else {
print "You've entered an invalid email address!";
}
?>
表单 HTML 代码:
<form name="contactform" id="contactform" method="post" action="/contact/" _lpchecked="1">
<ul class="form-block">
<!-- HONEYPOT -->
<li class="on-no-robots" style="height:0px; text-indent:-9999px; font-size:0px; overflow:hidden;">
<label>Humans Don't Submit This!! If you can see this, you don't have CSS, and you scare me. This is just here to filter out automated comments!</label>
<input name="robotest" id="robotest" type="text" />
</li>
<!-- HONEYPOT -->
<li class="third">
<label for="name">Name</label>
<input type="text" name="name" id="name" value="" class="required" />
</li>
<li class="third">
<label for="email">Email Address</label>
<input type="email" name="email" id="email" value="" class="required email" />
</li>
<li class="third">
<label for="phone">Phone Number</label>
<input type="text" name="phone" id="phone" value="" />
</li>
</ul>
<h3>How can we help you?</h3>
<ul class="form-block">
<li class="full">
<textarea name="comments" id="comments" class="required"></textarea>
</li>
<li>
<input id="submitButton" type="submit" value="Talk to us" onclick="_gaq.push(['_trackEvent', 'Conversions', 'Contact', 'Contact Form']);" />
</li>
</ul>
</form>
我也一直在表单的“提交”按钮上使用 Google Analytics 的事件跟踪,如下:
<input id="submitButton" type="submit" value="Talk to us" onclick="_gaq.push(['_trackEvent', 'Conversions', 'Contact', 'Contact Form']);" />
我可以测试一封电子邮件,它工作正常。然而,看看我的分析,有几天人们点击了“发送”按钮(触发分析事件)但我没有收到电子邮件。这可能是因为他们没有正确填写表格,但我不确定。我的 Gmail 垃圾邮件过滤器中没有任何内容。
有什么方法可以 (a) 与我的主机检查是否有任何未正确发送的“被困”电子邮件,以及 (b) 调整代码以使这些误报(如果它们是误报)不会t 发生?
显然,最简单的原因是人们只是为了好玩而单击“提交”按钮而没有输入任何内容,从而触发了分析事件。这些转换中的每一个都价值约 1500 美元,所以我想尽可能确定它们不是没有通过电子邮件发送给我的真正转换!
干杯,伙计们。