Blob Blame History Raw
#!/usr/bin/perl
#
# Usage:	inboxfer inputfile
#
# Purpose:	Transfer messages from Berkeley-format inbox to Cyrus inbox
#
# Input:	Text file containing one username per line
#
# Warning:	Do not use this script to transfer messages into a Cyrus 
#		mailbox that already contain messages. Existing messages 
#		will be overwritten.
#
#$Id: inboxfer,v 1.1 2004/02/04 12:59:42 karsten Exp $

$mailstore = "/var/spool/imap";  # Cyrus mailstore
$oldspool  = "/var/spool/mail";       # Old mail spool
$cat       = "/bin/cat";              # /usr/bin/cat on Solaris
$formail   = "/usr/bin/formail";
$pwd       = "/usr/lib/cyrus-imapd";
$cpmsg     = "cpmsg";               

$cmd       = "$formail -n 20 -s $pwd/$cpmsg";

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

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

while (<USERS>) {
    chop;
    $inbox = "$oldspool/$_";
    $prefix = substr($_,0,1);
    system("$cat $inbox | $cmd $mailstore/$prefix/user/$_");
}