繁体   English   中英

php发送空白电子邮件

[英]php sends blank e-mail

由于某种原因,我们每天从支持页面收到大约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为例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM