Skip to Main Content
Managing IMAP
book

Managing IMAP

by Dianna Mullet, Kevin Mullet
September 2000
Beginner content levelBeginner
408 pages
10h 29m
English
O'Reilly Media, Inc.
Content preview from Managing IMAP

inboxfer

inboxfer is a Perl script that was used in Chapter 9 to move messages from a Berkeley format inbox (e.g., /var/mail/johndoe) into a Cyrus inbox. The script (shown in Example A-3) assumes that the Cyrus mailbox already exists and that formail   is available on the machine where the script runs.[87] inboxfer takes the name of the file containing usernames, one per line, as input.

Example A-3. inboxfer

#!/usr/local/bin/perl

## Purpose: Extract messages from /var/mail mailbox 
##          and populate the Cyrus INBOX.

$scripts   = "/home/cyrus/bin";       # Location of this script
$mailstore = "/var/spool/imap/user";  # Cyrus mailstore
$oldspool  = "/var/oldmail";          # Old mail spool

$cmd       = "/usr/local/bin/formail -n 20 -s $scripts/cpmsg";

$users = "$ARGV[0]";
if (!$users) { die "Usage: $0 $users\\n"; }

open(USERS,"$users") || die "can't open $users";

while (<USERS>) {
    chop;
    $inbox = "$oldspool/$_";
    system("/usr/bin/cat $inbox | $cmd $mailstore/$_");
}

The system call pipes the contents of the incoming mail folder into a formail command. The formail command splits the folder up into separate mail messages and, in turn, pipes each mail message into another Perl script, cpmsg, for processing. cpmsg is the script that actually copies the message into the Cyrus mailbox. cpmsg is shown in Example A-4 .

formail increments an environment variable, FILENO, each time it finds a new message in the Berkeley folder. cpmsg takes advantage of the FILENO variable to come up with a unique numbering scheme for ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
Why Sleep Is a Strategic Resource

Why Sleep Is a Strategic Resource

Gretchen Spreitzer, Christopher M. Barnes
The Kind Leader

The Kind Leader

Karyn Ross

Publisher Resources

ISBN: 059600012XSupplemental ContentCatalog PageErrata