mirror of
https://github.com/webmin/webmin.git
synced 2026-09-19 20:10:38 +01:00
Added a simple page for setting up an email autoresponder
This commit is contained in:
@@ -4,3 +4,5 @@ First version of this module, which allows simple Procmail configuration.
|
||||
Added a message to the module's main page to detect system-level mail aliases (in /etc/aliases) that would forward email to the user to a different destination.
|
||||
---- Changes since 1.280 ----
|
||||
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.
|
||||
|
||||
35
filter/edit_auto.cgi
Normal file
35
filter/edit_auto.cgi
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Show a page for just adding, editing or removing an autoreply message
|
||||
|
||||
require './filter-lib.pl';
|
||||
&ReadParse();
|
||||
|
||||
&ui_print_header(undef, $text{'auto_title'}, "");
|
||||
|
||||
# Get the autoreply filter, if any
|
||||
@filters = &list_filters();
|
||||
($filter) = grep { $_->{'actionreply'} } @filters;
|
||||
|
||||
print &ui_form_start("save_auto.cgi", "post");
|
||||
print &ui_table_start($text{'auto_header'}, "width=100%", 2);
|
||||
|
||||
# Autoreply enabled?
|
||||
print &ui_table_row($text{'auto_enabled'},
|
||||
&ui_yesno_radio("enabled", $filter ? 1 : 0));
|
||||
|
||||
# Message
|
||||
print &ui_table_row($text{'auto_reply'},
|
||||
&ui_textarea("reply", $filter->{'reply'}->{'autotext'}, 5, 80));
|
||||
|
||||
# Period
|
||||
$r = $filter->{'reply'};
|
||||
$period = $r->{'replies'} && $r->{'period'} ? int($r->{'period'}/60) :
|
||||
$r->{'replies'} ? 60 : undef;
|
||||
print &ui_table_row($text{'auto_period'},
|
||||
&ui_opt_textbox("period", $period, 3, $text{'index_noperiod'}).
|
||||
" ".$text{'index_mins'});
|
||||
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'save'} ] ]);
|
||||
|
||||
&ui_print_footer("", $text{'index_return'});
|
||||
@@ -167,6 +167,23 @@ local ($filter) = @_;
|
||||
&procmail::modify_recipe($filter->{'recipe'});
|
||||
}
|
||||
|
||||
# insert_filter(&filter)
|
||||
# Like create_filter, but adds to the top of the .procmailrc
|
||||
sub insert_filter
|
||||
{
|
||||
local ($filter) = @_;
|
||||
local $recipe = { };
|
||||
&update_filter_recipe($filter, $recipe);
|
||||
local @pmrc = &procmail::parse_procmail_file(
|
||||
$filter->{'file'} || $procmail::procmailrc);
|
||||
if (@pmrc) {
|
||||
&procmail::create_recipe_before($recipe, $pmrc[0]);
|
||||
}
|
||||
else {
|
||||
&procmail::create_recipe($recipe);
|
||||
}
|
||||
}
|
||||
|
||||
# update_filter_recipe(&filter, &recipe)
|
||||
# Update a procmail recipe based on some filter
|
||||
sub update_filter_recipe
|
||||
@@ -433,5 +450,13 @@ if ($f->{'continue'}) {
|
||||
return $action;
|
||||
}
|
||||
|
||||
# can_simple_autoreply()
|
||||
# Returns 1 if the current filter rules are simple enough to allow an autoreply
|
||||
# to be added or removed.
|
||||
sub can_simple_autoreply
|
||||
{
|
||||
return 1; # Always true for now
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ if ($alias) {
|
||||
@filters = &list_filters();
|
||||
@links = ( &select_all_link("d"), &select_invert_link("d"),
|
||||
"<a href='edit.cgi?new=1'>$text{'index_add'}</a>" );
|
||||
($auto) = grep { $_->{'actionreply'} } @filters;
|
||||
if (&can_simple_autoreply() && !$auto) {
|
||||
push(@links, "<a href='edit_auto.cgi'>$text{'index_addauto'}</a>");
|
||||
}
|
||||
|
||||
@folders = &mailbox::list_folders();
|
||||
if (@filters) {
|
||||
|
||||
@@ -6,6 +6,7 @@ index_none=You do not have any mail filters defined yet. All email will be deliv
|
||||
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_add=Add a new email filter.
|
||||
index_addauto=Quick automatic reply setup.
|
||||
index_cspam=Email is spam
|
||||
index_cheader=Header $1 matches $2
|
||||
index_cre=Headers match $1
|
||||
@@ -83,3 +84,9 @@ aliases_your=Your mailbox
|
||||
aliases_delete=Delete mail
|
||||
aliases_other=Mailbox of user $1
|
||||
aliases_auto=Autoresponder with message $1
|
||||
|
||||
auto_title=Email Automatic Reply
|
||||
auto_header=Automatic email reply options
|
||||
auto_enabled=Automatic response enabled?
|
||||
auto_reply=Reply message
|
||||
auto_period=Minimum interval between replies
|
||||
|
||||
61
filter/save_auto.cgi
Normal file
61
filter/save_auto.cgi
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Create, update or delete an autoreply filter
|
||||
|
||||
require './filter-lib.pl';
|
||||
&ReadParse();
|
||||
|
||||
# Find existing autoreply filter object
|
||||
&lock_file($procmail::procmailrc);
|
||||
@filters = &list_filters();
|
||||
($old) = grep { $_->{'actionreply'} } @filters;
|
||||
$filter = $old;
|
||||
|
||||
if ($filter && !$in{'enabled'}) {
|
||||
# Just delete
|
||||
&delete_filter($filter);
|
||||
}
|
||||
elsif ($in{'enabled'}) {
|
||||
# Create or update
|
||||
if (!$filter) {
|
||||
$filter = { 'actionreply' => 1,
|
||||
'body' => 0,
|
||||
'continue' => 1 };
|
||||
}
|
||||
$in{'reply'} =~ /\S/ || &error($text{'save_ereply'});
|
||||
$in{'reply'} =~ s/\r//g;
|
||||
$filter->{'reply'}->{'autotext'} = $in{'reply'};
|
||||
|
||||
# From address (automatic)
|
||||
($froms, $doms) = &mailbox::list_from_addresses();
|
||||
$filter->{'reply'}->{'from'} = $froms->[0];
|
||||
|
||||
# File
|
||||
$filter->{'reply'}->{'autoreply'} ||=
|
||||
"$remote_user_info[7]/autoreply.$filter->{'index'}.txt";
|
||||
|
||||
# Reply period
|
||||
if ($in{'period_def'}) {
|
||||
# No autoreply period
|
||||
delete($filter->{'reply'}->{'replies'});
|
||||
delete($filter->{'reply'}->{'period'});
|
||||
}
|
||||
else {
|
||||
# Set reply period and tracking file
|
||||
$in{'period'} =~ /^\d+$/ ||
|
||||
&error($text{'save_eperiod'});
|
||||
$filter->{'reply'}->{'period'} = $in{'period'}*60;
|
||||
$filter->{'reply'}->{'replies'} ||=
|
||||
"$user_module_config_directory/replies";
|
||||
}
|
||||
|
||||
if ($old) {
|
||||
&modify_filter($filter);
|
||||
}
|
||||
else {
|
||||
&insert_filter($filter);
|
||||
}
|
||||
}
|
||||
|
||||
&unlock_file($procmail::procmailrc);
|
||||
&redirect("");
|
||||
|
||||
Reference in New Issue
Block a user