如何从我的PHP代码中停止幻影电子邮件? [英] How do I stop the Phantom Emails from my PHP code?

查看:67
本文介绍了如何从我的PHP代码中停止幻影电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用带有联系表格和php动作的html5网站来接收联系电子邮件。我已经在我的PHP中尝试了几个不同的代码,但没有阻止空白的电子邮件来。我的代码确实启用了google analytics,但是已经通过robot.txt阻止了抓取工具。这是我的代码。



PHP代码



foreach($ _GET as $ Field => $价值){

if($ Value!=''){

$ body。=$ Field:$ Value \ n;

}

}

$ name = trim(htmlentities($ _ GET ['name'],ENT_QUOTES,'utf-8'));



$ email = trim(htmlentities($ _ GET ['email'],ENT_QUOTES,'utf-8'));



$ phone = trim(htmlentities($ _ GET ['phone'],ENT_QUOTES,'utf-8'));



$ messages = trim(htmlentities( $ _REQUEST ['messages'],ENT_QUOTES,'utf-8'));





if(strlen($ name)= = 0)

{

echo> http://www.mason372.org/error.html';

}



if(strlen($ email)== 0)

{

echo> ; http://www.mason372.org/error.html';

}





$ to =junior.8791@gmail.com;



$ message =姓名:。$ name;



$ message。=\ n\\\
Email:。$ email;



$ message。= \ n\\\
Phone:。$ phone;



$ message。=\ n \ nMessage:。$ message;



$ headers =来自:$ email;



$ headers。=\ nReply-To:$ email ;



$成功=邮件($ to,$ subject,$ message,$ headers);





if($ success){



echo> http://www.mason372.org/thankyou。 html';



}否则{



echo> http:// www .mason372.org / error.html';



}



?>

联系表格



< form action =email.phpmethod =postid =form>

I'm currently using an html5 website with a contact form and a php action to receive contact emails. I've tried a few different codes in my php but non have stopped the blank emails from coming. I do have google analytics enables on my code but have blocked the crawler through robot.txt. Here is my code.

PHP CODE

foreach ($_GET as $Field=>$Value) {
if($Value != ''){
$body .= "$Field: $Value\n";
}
}
$name = trim(htmlentities($_GET['name'],ENT_QUOTES,'utf-8'));

$email = trim(htmlentities($_GET['email'],ENT_QUOTES,'utf-8'));

$phone = trim(htmlentities($_GET['phone'],ENT_QUOTES,'utf-8'));

$messages = trim(htmlentities($_REQUEST['messages'],ENT_QUOTES,'utf-8'));


if (strlen($name) == 0 )
{
echo """>http://www.mason372.org/error.html'";
}

if (strlen($email) == 0 )
{
echo """>http://www.mason372.org/error.html'";
}


$to = "junior.8791@gmail.com";

$message = "Name: ".$name;

$message.="\n\nEmail: ".$email;

$message.="\n\nPhone: ".$phone;

$message .= "\n\nMessage: ".$messages;

$headers = "From: $email";

$headers .="\nReply-To: $email";

$success = mail($to, $subject, $message, $headers);


if ($success) {

echo """>http://www.mason372.org/thankyou.html'";

} else {

echo """>http://www.mason372.org/error.html'";

}

?>
CONTACT FORM

<form action="email.php" method="post" id="form">









< input type =textclass =namename =nameid =name placeholder =Namevalue =aria-describedby =name-formatrequired aria-required =truepattern =[A-Za-z-0-9] + \ s [A-Za-z -'0-9] +title =eg'John Doe'required =/>




<input type="text" class="name" name="name" id="name" placeholder="Name" value="" aria-describedby="name-format" required aria-required="true" pattern="[A-Za-z-0-9]+\s[A-Za-z-'0-9]+" title="e.g.'John Doe'" required="" />






< input type =emailclass =emailname =emailid =emailplaceholder =Emailrequired = />




<input type="email" class="email" name="email" id="email" placeholder="Email" required="" />












< input type =telclass =telname =phoneid =phonename = phonetype =textplaceholder =Phone Numberpattern =(?:\(\\\ {3} \)| \d {3})[ - ]?\d {3} [ - ]?\d {4}必填/>




<input type="tel" class="tel" name="phone" id="phone" name="phone" type="text" placeholder="Phone Number" pattern="(?:\(\d{3}\)|\d{3})[- ]?\d{3}[- ]?\d{4}" required />












& lt; textarea name =messagesid =messagesplaceholder =Message>< / textarea>


<textarea name="messages" id="messages" placeholder="Message"></textarea>




< br $>







< input type =submitclass =按钮value =发送消息>

< input type =resetclass =button button-altvalue =Clear Form>

<input type="submit" class="button" value="Send Message">
<input type="reset" class="button button-alt" value="Clear Form">

推荐答案

_GET as


Field =>
Field=>


Value ){

if(
Value) {
if(


这篇关于如何从我的PHP代码中停止幻影电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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