Linux Training

Linux training for private, public & voluntary sector.

0793 572 8612

City LinUX sample scripts - arcmail

NAME

arcmail - moves old mail from a users current Maildir mailbox. The mail is sorted into annual archive folders.

SYNOPSIS

arcmail [ -c <config_file> ] [ -d ] [ -i <company id> ] [ -l ] [ -m <max> ] [ -n ] [ -v ] <mail_account> | [ -V ]

AVAILABILITY

arcmail is a Bourne shell script which should work equally well on all versions of UNIX, Linux and Mac OS X.

DESCRIPTION

arcmail uses " ssh " to connect to a postfix mail server to archive mail where the number of messages held in and INBOX exceeds the prescribed limit.

The limit may be set on the command line or in the configuration file. (The default limit is 5000).

The oldest messages are sorted by the year of last modification and are deposited in annualised sub-folders of " .Archive ". E.g. " .Archive.2014 ".

The script was developed to assist a client company which experiencing performance problems with INBOXes with some key workers holding in excess of 14,000 messages in their INBOX. For legal reasons the company was anxious to retain access to all old e-mail. By using unsubscribed archive folders the burden on the IMAP server and the local Apple e-mail clients is much reduced while still retaining occasional access via web-mail (using Horde in this instance). Access by the usual mail client is still available at a pinch but the burden on both client and server is much reduced.

If the archive folders do not exist they are created as required by the script. NB . The script expects that the administrator will have ssh access to the mail server and will be able to use sudo to obtain superuser privileges.

OPTIONS

-c    Use the specified configuration file in preference to the default "/usr/local/etc/arcmail.cf" . If no configuration file is found the script will print an error message to screen and will terminate. Options set on the command line supercede those found in the config file.

-d    Set debug mode on. The -x    option is set within the shell and each command in the script is echoed to the console.

.BI -i <company id> The company id is added to the logs. This is necessary if activity reports are to be generated for clients from the logs.

-l    Use the local syslog facility to log that the check has been made and record the number of messages returned.

-m <max> Messages in excess of the maximum threshold will be moved to the .Archive sub-folders.

-n    <mail_addr> Notifications of the number of messages moved will be sent to " .IR mail_addr ".

-v    Set verbose mode on.

<mail_address> If the mail domain cannot be resolved then an error message is printed and the script exits. The mail domain name and mail user name is used to find the path to the INBOX current folder on the remote server. The base directory is expected to be " /var/qmail/mailnames/ " but this may be set in the config file.

-V    Print the version details and exit.

FILES

arcmail.cf.

EXAMPLES

arcmail -v -l -m 500 fulford@fulford.net 

If " fulford.net " can be successfully resolved a ssh connection is made to the host and the number of messages in /var/qmail/mailnames/fulford.net/fulford/Maildir/cur are counted.

If the total exceeds the maximum of 500 set with the -m option the oldest messages will sorted by the year of last change and moved to mailboxes designated .IR .Archive.2013, .Archive.2014, .Archive.2015 etc.

SEE ALSO

chkmail, lsbounced, msg_cnt, msg_del.

AUTHOR

Clifford W Fulford, City Linux. Contact fulford@fulford.net or +44 (0)709 229 5385.


The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.