【问题标题】:Contact form produces unwanted results from server联系表格从服务器产生不需要的结果
【发布时间】:2022-02-10 21:08:15
【问题描述】:

我终于找到了一个有效的联系表格 - 将它插入我的三个站点,现在问题是我每天都收到来自我自己的网络托管服务器 Ionos 的所有三个站点的垃圾邮件,毫无意义的邮件(屏幕截图)。

我联系了 Ionos:“这是一个从网络空间发送电子邮件的邮件功能,需要停止发送添加的电子邮件的脚本。”

我问如何阻止它,答案是:“脚本不在我们的支持范围内”,这很丰富,来自一个网络托管站点。

email screenshot

'发送邮件'php。

<?php
/*
This first bit sets the email address that you want the form to be submitted to.
You will need to change this value to a valid email address that you can access.
*/
$webmaster_email = "legion@naturalblood.co";

/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = "feedback_form.html";
$error_page = "error_message.html";
$thankyou_page = "thank_you.html";

/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
*/
$email_address = $_REQUEST['email_address'] ;
$comments = $_REQUEST['comments'] ;
$first_name = $_REQUEST['first_name'] ;
$msg = 
"First Name: " . $first_name . "\r\n" . 
"Email: " . $email_address . "\r\n" . 
"Comments: " . $comments ;

/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
*/
function isInjected($str) {
    $injections = array('(\n+)',
    '(\r+)',
    '(\t+)',
    '(%0A+)',
    '(%0D+)',
    '(%08+)',
    '(%09+)'
    );
    $inject = join('|', $injections);
    $inject = "/$inject/i";
    if(preg_match($inject,$str)) {
        return true;
    }
    else {
        return false;
    }
}

// If the user tries to access this script directly, redirect them to the feedback form,
if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}

// If the form fields are empty, redirect to the error page.
elseif (empty($first_name) || empty($email_address)) {
header( "Location: $error_page" );
}

/* 
If email injection is detected, redirect to the error page.
If you add a form field, you should add it here.
*/
elseif ( isInjected($email_address) || isInjected($first_name)  || isInjected($comments) ) {
header( "Location: $error_page" );
}

// If we passed all previous tests, send the email then redirect to the thank you page.
else {

    mail( "$webmaster_email", "Message from amatoria.com", $msg );

    header( "Location: $thankyou_page" );
}
?>

【问题讨论】:

  • 他们说脚本不在他们的支持范围内,他们并不丰富。他们做网络托管,而不是编程。
  • @Dokik 如果我支付 Ionos Premium 以获得托管网站的特权,那么我应该期望支持停止从 Ionos 发送垃圾 - 一些代码的帮助不应该超出他们的范围。如果你只能用你自己的垃圾来回答我的问题,那么我建议堆栈溢出不适合你。
  • 我现在不太明白,你是说 ionos 正在发送垃圾邮件?我看到的方式是你从你自己的网页上用你自己的表格收到垃圾邮件。还是你使用了 ionos 的函数?
  • 看邮件截图:发件人是Ionos - 'name: 1, email: 1, cmets: 1.'这是垃圾。我不能简单地将它过滤到垃圾箱,因为真正的电子邮件是通过这个地址发送的。

标签: php html ionos


【解决方案1】:

尝试将 google recaptcha 添加到联系表单中。这样机器人或脚本就无法向您发送电子邮件。

见:https://www.google.com/recaptcha/about/

【讨论】:

  • 感谢您的建议,但我不会将 Goo 可恶的 recaptcha 强加给无辜者。
猜你喜欢
  • 2018-07-19
  • 2013-01-06
  • 1970-01-01
  • 1970-01-01
  • 2020-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-22
相关资源
最近更新 更多