diff --git a/mailscanner/conf.php.example b/mailscanner/conf.php.example
index 70f8450bc..e42eaa7e1 100644
--- a/mailscanner/conf.php.example
+++ b/mailscanner/conf.php.example
@@ -49,6 +49,11 @@ define('USER_SELECTABLE_LANG', 'de,en,es-419,fr,it,ja,nl,pt_br');
// This can also be set individually per user in the MailWatch GUI for greater flexibility.
define('SESSION_TIMEOUT', 600);
+// MaxMind License key
+// A free license key from MaxMind is required to download GeoLite2 data
+// https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/
+// define('MAXMIND_LICENSE_KEY', 'mylicensekey');
+
// Database settings
//
// As this file might be publically readable. It might be very userful to
diff --git a/mailscanner/functions.php b/mailscanner/functions.php
index fb36dad2d..c0f18b974 100644
--- a/mailscanner/functions.php
+++ b/mailscanner/functions.php
@@ -4289,7 +4289,8 @@ function checkConfVariables()
'ENABLE_SUPER_DOMAIN_ADMINS' => array('description' => 'allows domain admins to change domain admins from the same domain'),
'USE_IMAP' => array('description' => 'use IMAP for user authentication'),
'IMAP_HOST' => array('description' => 'IMAP host to be used for user authentication'),
- 'IMAP_AUTOCREATE_VALID_USER' => array('description' => 'enable to autorcreate user from valid imap login')
+ 'IMAP_AUTOCREATE_VALID_USER' => array('description' => 'enable to autorcreate user from valid imap login'),
+ 'MAXMIND_LICENSE_KEY' => array('description' => 'needed to download MaxMind GeoLite2 data')
);
$results = array();
@@ -4642,6 +4643,10 @@ function validateInput($input, $type)
if (preg_match('/^[0-9]{1,5}$/', $input)) {
return true;
}
+ case 'maxmind':
+ if (preg_match('/^([0-9A-Za-z]{12}|[0-9A-Za-z]{16})$/', $input)) {
+ return true;
+ }
break;
default:
return false;
diff --git a/mailscanner/geoip_update.php b/mailscanner/geoip_update.php
index 08dcf01e0..1375c1714 100644
--- a/mailscanner/geoip_update.php
+++ b/mailscanner/geoip_update.php
@@ -33,7 +33,10 @@
html_start(__('geoipupdate15'), 0, false, false);
-if (!isset($_POST['run'])) {
+if (!defined('MAXMIND_LICENSE_KEY') || !validateInput(MAXMIND_LICENSE_KEY, "maxmind")) {
+ $error_message = __('geoipnokey15') . '
' . "\n";
+ die($error_message);
+} elseif (!isset($_POST['run'])) {
echo '