Wiki

Aller au contenu | Aller au menu | Aller à la recherche

 

Goals

This script purges IMAP mailboxes of old read mail.

Specifications

A mail-group is a set of mails which belong to the same thread. The date of the mail-group is the date of the more recent mail in it. A mail group is read if and all mails in it are read.

This script automates the task to remove read mail-group when they are older than a certain date.

This script use a configuration file that can be found in .config/admin-gallu/archivemail. This file is a ini file containing one section per mailbox group and a general section for mailbox independent settings. Section name for mailbox group are defined as "mailbox-group: group". In this section there is a list of folder prefix which helps to define a set of mailbox out of the list of the IMAP account real mailboxes (as Sent.). If a real mailbox satisfies belongs to two groups, it will be processed one time with the settings of each section matching it.

General settings:

  • imap-user: user of the IMAP account
  • imap-server: server of the IMAP account
  • imap-port: port of the IMAP server
  • imap-passwd: password of the IMAP account

Mailbox group settings:

  • folders: IMAP folders in which real mailboxes are looked for (, separated)
  • duration: days before deleting a mail-group
  • delete-unread: delete unread mail-group
  • purge-if-empty: destroy mailbox if empty (for empty Sent.*)
  • backup-mbox: don't destroy mail-group place them in this mbox
  • backup-mbox-compress: activate compression of mailbox

Parameters can also be set using command line, considering that name is the mailbox group section name:

  • --configuration file: read configuration file
  • --imap-user user: c.f. imap-user
  • --imap-server server: c.f. imap-server
  • --imap-port port: c.f. imap-port
  • --imap-passwd passwd: c.f. imap-passwd
  • --folders group folders: c.f. folder
  • --duration group duration: c.f. duration
  • [--delete-unread|--nodelete-unread] group: c.f. delete-unread
  • --purge-if-empty group: c.f. purge-if-empty
  • --backup-mbox group file: c.f. backup-mbox
  • [--backup-mbox-compress|--nobackup-mbox-compress] group: c.f. backup-mbox-compress
  • --dbug, --dry-run, --quiet

Implementation

Library

We use debian package as reference. This is the target system and this is a good base test to know if libraries are used and which one are common.

Base

  • Getopt::Long: in perl-base
  • Pod::Usage: in perl-modules
  • File::Spec: in perl-base
  • Carp::Assert: in libcarp-assert-perl

IMAP

API required:

  • connect/disconnect to IMAP server
  • retrieve a list of all mailbox
  • choose a mailbox
  • retrieve certain header of each mail
  • download/delete mail
  • keep mail status
  • delete folder

Available packages/libraries:

  • libmail-imapclient-perl
    • apt-cache rdepends (sarge): ldirectord, libmail-box-perl
    • API:
  • libnet-imap-perl
    • apt-cache rdepends (sarge): webmin-ldap-useradmin
    • API:

Mbox

API required:

  • open existing mailbox
  • create mailbox
  • append mail

Gzip

API required:

  • create/open/write/close a file compressed
  • work with mbox library

Lang: Perl

Status

In progress