gpt4 book ai didi

javascript - php 发送空白电子邮件

转载 作者:行者123 更新时间:2023-12-03 02:56:06 25 4
gpt4 key购买 nike

出于某种原因,我们每天从支持页面收到大约 5/10 封电子邮件,这些电子邮件是空的,没有填写任何输入字段,而且根本没有提取任何输入字段。电子邮件仅显示主题。

如果我们测试表单,它工作正常,并且电子邮件显示我们填写的信息,即使我们什么都不填写,我们仍然会收到一封说明输入字段名称的电子邮件。在网站支持页面上的用户记录中,当我们收到“空白”电子邮件时,似乎没有用户填写表单。

我需要一些帮助,因为我完全不知道如何解决这个问题。

Javascript:

$( document ).ready(function() {
var $form = $('form');
$form.submit(function() {
$.post($(this).attr('action'), $(this).serialize(), function(response) {


$('.email-popup-container').css({
"transform": "scale(.9)",
});


setTimeout(function(){

$('.email-popup-container').animate({
"margin-left": "+=1200px",
"opacity": "0",
}, 400, function(){

setTimeout(function(){
$('#email-popup').removeClass('is-visible').ready(function(){

$('.email-popup-container').css({
"transform": "scale(1)",
});
$('#contact-form')[0].reset();
$('.email-popup-container').animate({
"margin-left": "-=1200px",
}, 0
);
});
},150)
setTimeout(function(){
$.notify(" Thank you! We have recieved your e-mail.", {
delay: 4000,
color: "#fff",
background: "#1AC16D",
type: "success",
icon: "check",
align: "right",
animationType: "fade"
});

},400)

});




},600)



}, 'json');
return false;
});
});

php:

// configure
$from = 'New Message - Support Page <istillwebsite@donotreply.com>';
$sendTo = 'New Message - Support Page <sales@istillmail.com>';
$subject = 'Message from iStill Support Page';
$fields = array('name' => 'Name', 'surname' => 'Surname', 'phone' => 'Phone', 'email' => 'Email', 'message' => 'Message'); // array variable name => Text to appear in email
$okMessage = 'Contact form successfully submitted. Thank you, I will get back to you soon!';
$errorMessage = 'There was an error while submitting the form. Please try again later';

// let's do the sending

try
{
$emailText = "Someone sent a message from the support page\n=============================\n";

foreach ($_POST as $key => $value) {

if (isset($fields[$key])) {
$emailText .= "$fields[$key]: $value\n";
}
}

mail($sendTo, $subject, $emailText, "From: " . $from);

$responseArray = array('type' => 'success', 'message' => $okMessage);





}
catch (\Exception $e)
{
$responseArray = array('type' => 'danger', 'message' => $errorMessage);
}

if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$encoded = json_encode($responseArray);

header('Content-Type: application/json');

echo $encoded;
}
else {
echo $responseArray['message'];
}

?>

最佳答案

这是一种非常不安全的发送邮件方式。有人可以调用您的 .php 脚本并发送多封邮件。所以它可能是一个机器人或类似的东西,正在调用您的脚本。

为了防止这种情况,您可以使用 Google reCaptcha例如。

关于javascript - php 发送空白电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47612818/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com