mirror of
https://github.com/webmin/webmin.git
synced 2026-05-04 22:30:33 +01:00
Show global spam delivery, if configured
This commit is contained in:
@@ -7,3 +7,5 @@ Added an option to set the date range for which autoreplies are sent.
|
||||
---- Changes since 1.290 ----
|
||||
Added a simple page for setting up an email autoresponder.
|
||||
Display a warning if /etc/procmailrc is setup to always deliver to the inbox, which would prevent user-defined filters from working.
|
||||
If email classified as spam is delivered to some folder by a global Procmail configuration (either in /etc/procmailrc or a Virtualmin per-domain setting), display this on the list of filters.
|
||||
Changed the module name to Filter and Forward Mail.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
virtualmin_spam=/etc/webmin/virtual-server/lookup-domain.pl
|
||||
warn_procmail=1
|
||||
alias_files=/etc/aliases /etc/postfix/aliases /etc/mail/aliases
|
||||
virtualmin_config=/etc/webmin/virtual-server
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
virtualmin_spam=Full path to Virtualmin spam user lookup program,3,Not installed,40
|
||||
virtualmin_config=Full path to Virtualmin config directory,3,Not installed
|
||||
warn_procmail=Show warning if Procmail is not installed?,1,1-Yes,0-No
|
||||
alias_files=Full path to global alias files,9,40,3,\t
|
||||
|
||||
@@ -12,9 +12,11 @@ if (&get_product_name() eq 'usermin') {
|
||||
# enabled before switching away from root
|
||||
if ($config{'virtualmin_spam'} && -x $config{'virtualmin_spam'}) {
|
||||
local $out = `$config{'virtualmin_spam'} $remote_user </dev/null 2>/dev/null`;
|
||||
$out =~ s/\r|\n//g;
|
||||
if ($out =~ /\d/) {
|
||||
# Yes - we can show the user this
|
||||
$global_spamassassin = 2;
|
||||
$virtualmin_domain_id = $out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,12 +258,12 @@ local ($filter1, $filter2) = @_;
|
||||
&procmail::swap_recipes($filter1->{'recipe'}, $filter2->{'recipe'});
|
||||
}
|
||||
|
||||
# file_to_folder(file, &folders, [homedir])
|
||||
# file_to_folder(file, &folders, [homedir], [fake-if-missing])
|
||||
# Given a path like mail/foo or ~/mail/foo or $HOME/mail/foo or
|
||||
# /home/bob/mail/foo, returns the folder object for it.
|
||||
sub file_to_folder
|
||||
{
|
||||
local ($file, $folders, $home) = @_;
|
||||
local ($file, $folders, $home, $fake) = @_;
|
||||
$home ||= $remote_user_info[7];
|
||||
$file =~ s/^\~/$home/;
|
||||
$file =~ s/^\$HOME/$home/;
|
||||
@@ -270,6 +272,21 @@ if ($file !~ /^\//) {
|
||||
}
|
||||
local ($folder) = grep { $_->{'file'} eq $file ||
|
||||
$_->{'file'}.'/' eq $file } @$folders;
|
||||
if (!$folder && $fake) {
|
||||
# Create a fake folder object to match
|
||||
$folder = { 'file' => $file,
|
||||
'type' => 1,
|
||||
'fake' => 1 };
|
||||
if ($folder->{'file'} =~ s/\/$//) {
|
||||
$folder->{'type'} = 2;
|
||||
}
|
||||
$folder->{'file'} =~ /\/\.?([^\/]+)$/;
|
||||
$folder->{'name'} = $1;
|
||||
if (lc($folder->{'name'}) eq 'spam') {
|
||||
$folder->{'spam'} = 1;
|
||||
$folder->{'name'} = "Spam";
|
||||
}
|
||||
}
|
||||
return $folder;
|
||||
}
|
||||
|
||||
@@ -283,6 +300,33 @@ local @recipes = &procmail::parse_procmail_file(
|
||||
return &spam::find_spam_recipe(\@recipes) ? 1 : 0;
|
||||
}
|
||||
|
||||
# get_global_spam_path()
|
||||
# Returns the global path to which spam is delivered, typically by a
|
||||
# Virtualmin per-domain procmail file
|
||||
sub get_global_spam_path
|
||||
{
|
||||
if ($virtualmin_domain_id) {
|
||||
# Read the Virtualmin procmailrc for the domain
|
||||
local $vmpmrc = "$config{'virtualmin_config'}/procmail/".
|
||||
$virtualmin_domain_id;
|
||||
local @vmrecipes = &procmail::parse_procmail_file($vmpmrc);
|
||||
local $spamrec = &spam::find_file_recipe(\@vmrecipes);
|
||||
if ($spamrec) {
|
||||
return $spamrec->{'action'};
|
||||
}
|
||||
}
|
||||
# Also check the global /etc/procmailrc
|
||||
local @recipes = &procmail::parse_procmail_file(
|
||||
$spam::config{'global_procmailrc'});
|
||||
local $spamrec = &spam::find_file_recipe(\@recipes);
|
||||
if ($spamrec) {
|
||||
return $spamrec->{'action'};
|
||||
}
|
||||
else {
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
sub has_spamassassin
|
||||
{
|
||||
return &foreign_installed("spam");
|
||||
|
||||
@@ -58,12 +58,30 @@ if (@filters) {
|
||||
@filters > 1 ? ( $text{'index_move'} ) : ( ),
|
||||
], 100, 0, \@tds);
|
||||
|
||||
# Add a magic non-editable row for global spamassassin run
|
||||
# Add a magic non-editable row(s) for global spamassassin run
|
||||
if (&get_global_spamassassin()) {
|
||||
print &ui_columns_row(
|
||||
[ "", $text{'index_calways'}, $text{'index_aspam'},
|
||||
@filters > 1 ? ( "" ) : ( ) ],
|
||||
\@tds);
|
||||
$spamfile = &get_global_spam_path();
|
||||
if ($spamfile) {
|
||||
$folder = &file_to_folder($spamfile, \@folders, 0, 1);
|
||||
$id = &mailbox::folder_name($folder);
|
||||
if ($folder->{'fake'}) {
|
||||
$sflink = "<u>$folder->{'name'}</u>";
|
||||
}
|
||||
else {
|
||||
$sflink =
|
||||
"<a href='../mailbox/index.cgi?id=$id'>".
|
||||
"$folder->{'name'}</a>";
|
||||
}
|
||||
print &ui_columns_row(
|
||||
[ "", $text{'index_cspam'},
|
||||
&text('index_afolder', $sflink),
|
||||
@filters > 1 ? ( "" ) : ( ) ],
|
||||
\@tds);
|
||||
}
|
||||
}
|
||||
|
||||
# Show editable rows
|
||||
@@ -120,7 +138,25 @@ else {
|
||||
print "<b>$text{'index_none2'}</b><p>\n";
|
||||
}
|
||||
elsif (&get_global_spamassassin()) {
|
||||
print "<b>$text{'index_none3'}</b><p>\n";
|
||||
$spamfile = &get_global_spam_path();
|
||||
if ($spamfile) {
|
||||
$folder = &file_to_folder($spamfile, \@folders, 0, 1);
|
||||
print "<b>";
|
||||
$id = &mailbox::folder_name($folder);
|
||||
if ($folder->{'fake'}) {
|
||||
print &text('index_none4',
|
||||
"<u>$folder->{'name'}</u>");
|
||||
}
|
||||
else {
|
||||
print &text('index_none4',
|
||||
"<a href='../mailbox/index.cgi?id=$id'>".
|
||||
"$folder->{'name'}</a>");
|
||||
}
|
||||
print "</b><p>\n";
|
||||
}
|
||||
else {
|
||||
print "<b>$text{'index_none3'}</b><p>\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
print "<b>$text{'index_none'}</b><p>\n";
|
||||
|
||||
@@ -4,7 +4,9 @@ index_action=Filter action
|
||||
index_move=Move
|
||||
index_none=You do not have any mail filters defined yet. All email will be delivered to your Inbox.
|
||||
index_none2=None of your existing Procmail rules are simple enough to display here.
|
||||
index_none3=You do not have any mail filters defined yet. All email will be delivered to your Inbox, after spam filtering.
|
||||
index_none3=You do not have any mail filters defined yet. All email will be delivered to your Inbox, after spam classification.
|
||||
index_none4=You do not have any mail filters defined yet. All email will be deliverted to your Inbox, except spam which will be sent to the folder $1.
|
||||
index_none5=You do not have any mail filters defined yet. All email will be deliverted to your Inbox, except spam which will be sent to the file $1.
|
||||
index_add=Add a new email filter.
|
||||
index_addauto=Quick automatic reply setup.
|
||||
index_cspam=Email is spam
|
||||
|
||||
Reference in New Issue
Block a user