#!/usr/bin/perl # Mailbox Size Listing Script, version 1.0 # Copyright 2002, Joshua Cantara # This program is licensed under the GPL. use CLI; use Net::SMTP; ########################################################## # Change the variables below to your settings # ########################################################## my $domain = 'yourdomain.com'; my $cgserver = '127.0.0.1'; my $login = 'postmaster@yourdomain.com'; my $password = 'password'; # Change this variable to whatever size, in megs, you # consider too large for an account. my $toobig = '10'; # The account from which you wish to have the notices # appear they are coming from. May be REQUIRED for servers # with smtp auth enabled. $from = "notices"; ########################################################## # You should not have to change anything below this point# ########################################################## my $average = ($toobig/2); my $username; my $storage = 0; my $accountdata; my $realname; my $cli = new CGP::CLI ( { PeerAddr => $cgserver, PeerPort => 106, login => $login, password => $password } ) || die "Cannot login to CGPro"; my $accounts = $cli->ListAccounts($domain) || die $cli->getErrMessage; foreach $username (sort keys %$accounts) { $storage = 0; unless ($storage = $cli->GetAccountInfo("$username\@$domain",'StorageUsed')) { $storage = "0"; } $accountdata = $cli->GetAccount("$username\@$domain"); $realname = @$accountdata{'RealName'}; $storage = sprintf("%.2f",($storage/1048576)); if ($storage > 10) { my $smtp = Net::SMTP->new($cgserver); my $toaddress = "$username\@$domain"; $smtp->mail($ENV{USER}); $smtp->to($toaddress); $smtp->data(); $smtp->datasend(qq|To: $toaddress\n|); $smtp->datasend(qq|From: | . $from . "@" . $domain . "\n"); $smtp->datasend(qq|Subject: An important notice about your email account.\n\n|); $smtp->datasend(qq|$realname, This is an automatically generated message informing you that your email account is using more space than is deemed appropriate on the email server. Large accounts pose many problems, but most noticable to you will be slow access to your mail. The average size for an account is around $average megabytes, and the upper limit is $toobig. Your account currently has $storage megabytes of data in it. Please take some time as soon as possible to clean up your mailboxes. Here are some suggestions on how to reduce the size of your account: 1. Empty your Trash regularly if you are using one. 2. Empty your "Sent Items" folder if you are using one. 3. Remember to "Purge Deleted" messages after marking them. Simply marking them leaves them in your mailbox forever. 3. Emails with attachments take up the most room, so please save the attachments to your computer as soon as possible and delete the emails completely by emptying your trash or purging your marked messages. Exceptions are made for when you are using your email account to help transfer documents from one PC to another. 4. Sort your mailboxes by size by clicking on the "Size" column heading. This will let you see which messages are taking up the most room. Any messages marked "100k" or greater and any message with an "M" after it are considered VERY large and should be deleted. 5. Every few months check through your mailboxes for old messages you no longer need and delete them. Mailboxes are sorted by date automatically, so use the arrows to move to the end and you will find your oldest messages. Thank you for your time. |); $smtp->dataend(); $smtp->quit; } } $cli->Logout; exit;