Cc option for quota emails
authorJamie Cameron <jcameron@webmin.com>
Thu, 11 Sep 2008 00:01:51 +0000 (00:01 +0000)
committerJamie Cameron <jcameron@webmin.com>
Thu, 11 Sep 2008 00:01:51 +0000 (00:01 +0000)
quota/CHANGELOG
quota/email.pl
quota/lang/en
quota/list_users.cgi
quota/save_email.cgi

index acd63cd..0a675b1 100644 (file)
@@ -32,3 +32,5 @@ Added a Module Config option to show both hard and/or soft quota percentages.
 Quotas are considered active for a filesystem if the usrquota or grpquota options are on in /etc/mtab, even if missing from /etc/fstab.
 ---- Changes since 1.400 ----
 If a user to email is a Virtualmin domain owner, send email to the domain's contact address.
+---- Changes since 1.430 ----
+Email to users who are over quota on some filesystem can also be Cc'd to another address, such as the system administrator.
index 0a08c3c..8a95f7c 100755 (executable)
@@ -78,6 +78,7 @@ foreach $k (keys %config) {
                                $config{'email_from_'.$f},
                                $user{$i,'gblocks'},
                                'email',
+                               $config{'email_cc_'.$f},
                                );
 
                        # Save last email time
@@ -170,7 +171,8 @@ foreach $k (keys %config) {
 
 sub send_quota_mail
 {
-local ($user, $addr, $limit, $used, $fs, $percent, $from, $grace, $suffix) =@_;
+local ($user, $addr, $limit, $used, $fs, $percent, $from, $grace, $suffix,
+       $ccaddr) = @_;
 local $bsize = &block_size($fs);
 if ($bsize) {
        $used = &nice_size($used*$bsize);
@@ -208,7 +210,7 @@ else {
        }
 &mailboxes::send_text_mail($from || &mailboxes::get_from_address(),
                           $addr,
-                          undef,
+                          $ccaddr,
                           $subject,
                           $body);
 }
index 8e8a5ec..c7ebaf7 100644 (file)
@@ -266,6 +266,8 @@ lusers_domain=Domain for user addresses
 luser_virtualmin=Get domain from Virtualmin?
 lusers_from=From: address for email
 lusers_mass=Update Selected Users
+lusers_cc=Also Cc: email to
+lusers_nocc=Don't Cc
 
 grace_seconds=Seconds
 grace_minutes=Minutes
@@ -297,6 +299,7 @@ email_einterval=Missing or invalid interval
 email_epercent=Missing or invalid usage percentage
 email_edomain=Missing or invalid mail domain
 email_efrom=Missing or invalid From: address
+email_ecc=Missing or invalid Cc: address
 email_msg=Disk usage for user $1 on filesystem $2 has reached $3% of the\nallowed quota.\n\n$4 of disk space is being used, out of a maximum of $5.
 gemail_msg=Disk usage for group $1 on filesystem $2 has reached $3% of the\nallowed quota.\n\n$4 of disk space is being used, out of a maximum of $5.
 email_subject=Disk quota exceeded
index 3c23b16..06e6fba 100755 (executable)
@@ -267,7 +267,11 @@ if ($access{'email'} && &foreign_check("cron") &&
 
        print &ui_table_row($text{'lusers_from'},
                    &ui_textbox("from", $config{"email_from_$f"} ||
-                                       'webmin@'.&get_system_hostname(), 20));
+                                       'webmin@'.&get_system_hostname(), 30));
+
+       print &ui_table_row($text{'lusers_cc'},
+               &ui_opt_textbox("cc", $config{"email_cc_$f"}, 30,
+                               $text{'lusers_nocc'}), 3);
 
        print &ui_table_end();
        print &ui_form_end([ [ 'save', $text{'lusers_apply'} ] ]);
index 6a7f10b..ba54168 100755 (executable)
@@ -14,6 +14,7 @@ if ($in{'email'}) {
        $in{'percent'} =~ /^[0-9\.]+$/ || &error($text{'email_epercent'});
        $in{'domain'} =~ /^[a-z0-9\.\-]+$/i || &error($text{'email_edomain'});
        $in{'from'} =~ /^\S+$/i || &error($text{'email_efrom'});
+       $in{'cc_def'} || $in{'cc'} =~ /^\S+$/i || &error($text{'email_ecc'});
        }
 
 # Save settings
@@ -25,6 +26,7 @@ $config{"email_percent_".$in{'filesys'}} = $in{'percent'};
 $config{"email_domain_".$in{'filesys'}} = $in{'domain'};
 $config{"email_virtualmin_".$in{'filesys'}} = $in{'virtualmin'};
 $config{"email_from_".$in{'filesys'}} = $in{'from'};
+$config{"email_cc_".$in{'filesys'}} = $in{'cc'};
 &save_module_config();
 &unlock_file($module_config_file);