2 # Change the procmail rule that delivers spam
4 require './spam-lib.pl';
5 &error_setup($text{'procmail_err'});
7 &set_config_file_in(\%in);
8 &can_use_check("procmail");
15 elsif ($in{'to'} == 1) {
16 $in{'mbox'} =~ /^\S+$/ || &error($text{'setup_efile'});
19 elsif ($in{'to'} == 2) {
20 $in{'maildir'} =~ /^\S+$/ || &error($text{'setup_emaildir'});
21 $file = "$in{'maildir'}/";
23 elsif ($in{'to'} == 3) {
24 $in{'mhdir'} =~ /^\S+$/ || &error($text{'setup_emhdir'});
25 $file = "$in{'mhdir'}/.";
27 elsif ($in{'to'} == 4) {
30 elsif ($in{'to'} == 5) {
31 $in{'email'} =~ /^\S+$/ || &error($text{'setup_eemail'});
36 # Find the existing recipe
37 &foreign_require("procmail", "procmail-lib.pl");
38 @pmrcs = &get_procmailrc();
39 $pmrc = $pmrcs[$#pmrcs];
40 @recipes = &procmail::parse_procmail_file($pmrc);
41 $spamrec = &find_file_recipe(\@recipes);
47 $spamrec->{'action'} = $file;
48 $spamrec->{'type'} = $type;
49 &procmail::modify_recipe($spamrec);
53 $spamrec = { 'flags' => [ ],
54 'conds' => [ [ '', '^X-Spam-Status: Yes' ] ],
57 &procmail::create_recipe($spamrec, $pmrc);
61 # Remove the recipe, to fall back to default delivery
62 &procmail::delete_recipe($spamrec);
66 if ($module_info{'usermin'} && $file ne "/dev/null") {
67 # Remember spam mail file
68 $userconfig{'spam_file'} = $file;
69 &write_file("$user_module_config_directory/config", \%userconfig);
73 &webmin_log("procmail");
74 &redirect($redirect_url);