Optionally enable spam filter for forwarding hosts
parent
8c8bfc0108
commit
ae6d7d63fc
|
@ -31,19 +31,52 @@ catch (PDOException $e) {
|
|||
|
||||
?>
|
||||
settings {
|
||||
<?php
|
||||
|
||||
/*
|
||||
// Start whitelist for forwarding hosts
|
||||
*/
|
||||
|
||||
<?php
|
||||
try {
|
||||
$stmt = $pdo->query("SELECT `host` FROM `forwarding_hosts`");
|
||||
$stmt = $pdo->query("SELECT `host` FROM `forwarding_hosts` WHERE `filter_spam` = 1");
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$rows = array();
|
||||
}
|
||||
|
||||
if (!empty($rows)) {
|
||||
?>
|
||||
whitelist_forwarding_hosts_with_spam_filter {
|
||||
priority = high;
|
||||
<?php
|
||||
foreach ($rows as $host):
|
||||
?>
|
||||
ip = "<?=$host;?>";
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
apply "default" {
|
||||
actions {
|
||||
reject = 999.9;
|
||||
greylist = 999.8;
|
||||
}
|
||||
}
|
||||
symbols [
|
||||
"WHITELIST_FORWARDING_HOST"
|
||||
]
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $pdo->query("SELECT `host` FROM `forwarding_hosts` WHERE `filter_spam` = 0");
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$rows = array();
|
||||
}
|
||||
|
||||
if (!empty($rows)) {
|
||||
?>
|
||||
whitelist_forwarding_hosts {
|
||||
|
|
|
@ -276,6 +276,7 @@ $tfa_data = get_tfa();
|
|||
<tr>
|
||||
<th style="min-width: 100px;"><?=$lang['edit']['host'];?></th>
|
||||
<th style="min-width: 100px;"><?=$lang['edit']['source'];?></th>
|
||||
<th style="min-width: 100px;"><?=$lang['user']['spamfilter'];?></th>
|
||||
<th style="text-align: right; min-width: 200px;"><?=$lang['admin']['action'];?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -284,15 +285,14 @@ $tfa_data = get_tfa();
|
|||
$forwarding_hosts = get_forwarding_hosts();
|
||||
if ($forwarding_hosts) {
|
||||
foreach ($forwarding_hosts as $host) {
|
||||
$source = $host->source;
|
||||
$host = $host->host;
|
||||
?>
|
||||
<tr id="data">
|
||||
<td><?=htmlspecialchars(strtolower($host));?></td>
|
||||
<td><?=htmlspecialchars(strtolower($source));?></td>
|
||||
<td><?=htmlspecialchars(strtolower($host->host));?></td>
|
||||
<td><?=htmlspecialchars(strtolower($host->source));?></td>
|
||||
<td><?=$host->filter_spam ? "✔" : "✘";?></td>
|
||||
<td style="text-align: right;">
|
||||
<div class="btn-group">
|
||||
<a href="delete.php?forwardinghost=<?=$host;?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['admin']['remove'];?></a>
|
||||
<a href="delete.php?forwardinghost=<?=$host->host;?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['admin']['remove'];?></a>
|
||||
</div>
|
||||
</td>
|
||||
</td>
|
||||
|
@ -319,6 +319,13 @@ $tfa_data = get_tfa();
|
|||
<input type="text" class="form-control" name="hostname" id="hostname" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" name="filter_spam"> <?=$lang['user']['spamfilter'];?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" name="add_forwarding_host" class="btn btn-default"><?=$lang['admin']['add'];?></button>
|
||||
|
|
|
@ -5094,7 +5094,7 @@ function get_u2f_registrations($username) {
|
|||
}
|
||||
function get_forwarding_hosts() {
|
||||
global $pdo;
|
||||
$sel = $pdo->prepare("SELECT host, source FROM `forwarding_hosts`");
|
||||
$sel = $pdo->prepare("SELECT * FROM `forwarding_hosts`");
|
||||
$sel->execute();
|
||||
return $sel->fetchAll(PDO::FETCH_OBJ);
|
||||
}
|
||||
|
@ -5111,6 +5111,7 @@ function add_forwarding_host($postarray) {
|
|||
}
|
||||
$source = $postarray['hostname'];
|
||||
$host = $postarray['hostname'];
|
||||
$filter_spam = !empty($postarray['filter_spam']);
|
||||
$hosts = array();
|
||||
if (preg_match('/^[0-9a-fA-F:\/]+$/', $host)) { // IPv6 address
|
||||
$hosts = array($host);
|
||||
|
@ -5133,10 +5134,15 @@ function add_forwarding_host($postarray) {
|
|||
if ($source == $host)
|
||||
$source = '';
|
||||
try {
|
||||
$stmt = $pdo->prepare("INSERT IGNORE INTO `forwarding_hosts` (`host`, `source`) VALUES (:host, :source)");
|
||||
if ($filter_spam) { // if the host already exists, REPLACE it with the spam filter turned on
|
||||
$stmt = $pdo->prepare("REPLACE INTO `forwarding_hosts` (`host`, `source`, `filter_spam`) VALUES (:host, :source, :filter_spam)");
|
||||
} else { // if the host already exists, IGNORE it no matter whether the spam filter is already turned on
|
||||
$stmt = $pdo->prepare("INSERT IGNORE INTO `forwarding_hosts` (`host`, `source`, `filter_spam`) VALUES (:host, :source, :filter_spam)");
|
||||
}
|
||||
$stmt->execute(array(
|
||||
':host' => $host,
|
||||
':source' => $source,
|
||||
':filter_spam' => $filter_spam ? 1 : 0,
|
||||
));
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
|
|
|
@ -3,7 +3,7 @@ function init_db_schema() {
|
|||
try {
|
||||
global $pdo;
|
||||
|
||||
$db_version = "01052017_1702";
|
||||
$db_version = "07052017_0824";
|
||||
|
||||
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
||||
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
|
@ -268,7 +268,8 @@ function init_db_schema() {
|
|||
"forwarding_hosts" => array(
|
||||
"cols" => array(
|
||||
"host" => "VARCHAR(255) NOT NULL",
|
||||
"source" => "VARCHAR(255) NOT NULL"
|
||||
"source" => "VARCHAR(255) NOT NULL",
|
||||
"filter_spam" => "TINYINT(1) NOT NULL DEFAULT '0'"
|
||||
),
|
||||
"keys" => array(
|
||||
"primary" => array(
|
||||
|
|
|
@ -472,7 +472,7 @@ $lang['admin']['no_record'] = 'Kein Eintrag';
|
|||
$lang['admin']['filter_table'] = 'Tabelle Filtern';
|
||||
$lang['admin']['empty'] = 'Keine Einträge vorhanden';
|
||||
$lang['admin']['forwarding_hosts'] = 'Weiterleitungs-Hosts';
|
||||
$lang['admin']['forwarding_hosts_hint'] = 'Eingehende Nachrichten werden von den hier gelisteten Hosts bedingungslos akzeptiert. Diese Hosts werden dann nicht mit DNSBLs abgeglichen oder Greylisting unterworfen. Von ihnen empfangener Spam wird nie abgelehnt und immer in den Spam-Ordner einsortiert. Die übliche Verwendung für diese Funktion ist, um Mailserver anzugeben, auf denen eine Weiterleitung zu Ihrem Mailcow-Server eingerichtet wurde.';
|
||||
$lang['admin']['forwarding_hosts_hint'] = 'Eingehende Nachrichten werden von den hier gelisteten Hosts bedingungslos akzeptiert. Diese Hosts werden dann nicht mit DNSBLs abgeglichen oder Greylisting unterworfen. Von ihnen empfangener Spam wird nie abgelehnt, optional kann er aber in den Spam-Ordner einsortiert werden. Die übliche Verwendung für diese Funktion ist, um Mailserver anzugeben, auf denen eine Weiterleitung zu Ihrem Mailcow-Server eingerichtet wurde.';
|
||||
$lang['admin']['forwarding_hosts_add_hint'] = 'Sie können entweder IPv4/IPv6-Adressen, Netzwerke in CIDR-Notation, Hostnamen (die zu IP-Adressen aufgelöst werden), oder Domainnamen (die zu IP-Adressen aufgelöst werden, indem ihr SPF-Record abgefragt wird oder, in dessen Abwesenheit, ihre MX-Records) angeben.';
|
||||
$lang['edit']['host'] = 'Host';
|
||||
$lang['edit']['source'] = 'Quelle';
|
||||
|
|
|
@ -484,7 +484,7 @@ $lang['admin']['no_record'] = 'No record';
|
|||
$lang['admin']['filter_table'] = 'Filter table';
|
||||
$lang['admin']['empty'] = 'No results';
|
||||
$lang['admin']['forwarding_hosts'] = 'Forwarding Hosts';
|
||||
$lang['admin']['forwarding_hosts_hint'] = 'Incoming messages are unconditionally accepted from any hosts listed here. These hosts are then not checked against DNSBLs or subjected to greylisting. Spam received from them is never rejected and always filed into the Junk folder. The most common use for this is to specify mail servers on which you have set up a rule that forwards incoming emails to your Mailcow server.';
|
||||
$lang['admin']['forwarding_hosts_hint'] = 'Incoming messages are unconditionally accepted from any hosts listed here. These hosts are then not checked against DNSBLs or subjected to greylisting. Spam received from them is never rejected, but optionally it can be filed into the Junk folder. The most common use for this is to specify mail servers on which you have set up a rule that forwards incoming emails to your Mailcow server.';
|
||||
$lang['admin']['forwarding_hosts_add_hint'] = 'You can either specify IPv4/IPv6 addresses, networks in CIDR notation, host names (which will be resolved to IP addresses), or domain names (which will be resolved to IP addresses by querying SPF records or, in their absence, MX records).';
|
||||
$lang['edit']['host'] = 'Host';
|
||||
$lang['edit']['source'] = 'Source';
|
||||
|
|
Loading…
Reference in New Issue