0

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

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

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

电子邮件截图

'发送邮件' 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" );
}
?>

4

1 回答 1

0

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

请参阅:https ://www.google.com/recaptcha/about/

于 2022-02-10T13:08:15.980 回答