diff --git a/html/inc/email.inc b/html/inc/email.inc
index cdc5551361..a66425bdcf 100644
--- a/html/inc/email.inc
+++ b/html/inc/email.inc
@@ -93,8 +93,13 @@ For further information and assistance with ".PROJECT.", visit
//
function is_valid_email_addr($addr) {
if (defined("USE_STOPFORUMSPAM") && USE_STOPFORUMSPAM && array_key_exists('REMOTE_ADDR', $_SERVER)) {
- $ip_addr = $_SERVER['REMOTE_ADDR'];
- $x = @file_get_contents("https://www.stopforumspam.com/api?ip=".$ip_addr."&email=".$addr);
+ $ip = $_SERVER['REMOTE_ADDR'];
+ // For obviously private IPs check just the email against SFS, otherwise check both IP and email
+ if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
+ $x = @file_get_contents("https://www.stopforumspam.com/api?ip=".$ip."&email=".$addr);
+ } else {
+ $x = @file_get_contents("https://www.stopforumspam.com/api?email=".$addr);
+ }
if (substr_count($x, 'yes')) {
return false;
}