cyrus-imapd/cpmsg
John Dennis 38f2261a6f auto-import cyrus-imapd-2.2.12-1.2.fc4 on branch devel from
cyrus-imapd-2.2.12-1.2.fc4.src.rpm
2005-04-15 20:24:15 +00:00

27 lines
614 B
Perl

#!/usr/bin/perl
#
# Usage: cat mailbox.txt | formail -s cpmsg
#
# where 'cpmsg' is the name of this script
#
# Purpose: Called by formail once for each mail message in a Berkeley-
# format mailbox
#
#$Id: cpmsg,v 1.1 2005/04/15 20:24:15 jdennis Exp $
$maildir = "$ARGV[0]";
if (!$maildir) { die "Usage: $0 $maildir"; }
# Formail increments this number for each message. The
# leading "0"'s must be removed (e.g. 001 becomes 1)
$filenum = ($ENV{FILENO} - 0) + 1;
open (OUTFILE,">$maildir/$filenum.");
while (<STDIN>) {
chop;
print OUTFILE "$_\015\012"; # Add CRLF to each line!
}
close OUTFILE;