PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : cyrus Format der mails



bp
20.02.02, 18:14
also ich habe folgendes Problem: Habe vor kurzen von dem Standart imap server der SuSE 7.3 auf den cyrus server umgestellt, dieser hat ein anderes mailformat. Wie kann ich die alten mails aus dem /var/mail Verzeichniss in die neuen Cyrus mailboxen kopieren, so das sie in den entsprechenden mailboxen auftauchen? Weiss jemand rat?

mpphp
20.02.02, 21:57
hi

ich denke du brauchst ein tool names user2cyrus, welches die alten im mbox format vorliegenden mails in imap-verständliche umwandelt

hier ein script:

# user2cyrus requires the NetxAP Perl module, which is freely available from CPAN.

#!/usr/local/bin/perl
#
# This is a modified version of a public domain script written by
# Steve Snodgrass (ssnodgra@fore.com).
#
# user2cyrus - Dump a user's Unix mail file into a Cyrus mailbox
#
# Usage: user2cyrus mbox
#
# Input: Name of an RFC 822 mail folder
#
# Dependency: NetxAP Perl module from CPAN
#
use File::Basename;
use Net::IMAP;

# Set this to the hostname of your IMAP server
$IMAPSERVER = "europa.acs.unt.edu";

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

chop ($whoami = `/usr/ucb/whoami`);
if ($whoami eq "root" || $whoami eq "cyrus") {
die "This script cannot be run by a privileged user!\n";
}

#
# Main Code
#

# Log in to Cyrus IMAP server
($user, $pass) = GetLogin( );
$imap = new Net::IMAP($IMAPSERVER, Synchronous => 1);
$response = $imap->login($user, $pass);
print "Login: ", $response->status, "-",
$response->status_text, "\n";

# cyrmailbox is the mailbox name on the Cyrus server
$cyrmailbox = "user." . "$user." . basename($mbox);

# Create the new mailbox. If the mailbox already exists, do not
# allow its contents to be overwritten!
$response = $imap->create($cyrmailbox);

print "Create: ", $response->status, "-",
$response->status_text, "\n";

if ($response->status eq "NO") {
print "Mailbox $cyrmailbox already exists on Cyrus server!\n";
print "Rename your file and try again.\n";
$response = $imap->logout( );
print "Logout: ", $response->status, "-",
$response->status_text, "\n";
exit;
}

# Copy the mbox
if (-s $mbox) {
TransferMbox($imap, $cyrmailbox, $mbox);
}

# Disconnect from IMAP server
$response = $imap->logout( );
print "Logout: ", $response->status, "-",
$response->status_text, "\n";

#
# Get username and password information
#
sub GetLogin {
my ($username, $password);

print "Enter your IMAP username: ";
chop ($username = <STDIN>);
system "stty -echo";
print "Enter your IMAP password: ";
chop ($password = <STDIN>);
system "stty echo";
print "\n";
return ($username, $password);
}

#
# Dump a Unix-style mbox file into a Cyrus folder
#
sub TransferMbox {
my ($imap, $mailbox, $mboxfile) = @_;

my $blank = 1;
my $count = 0;
my $message = "";
my $response;

print "Transferring $mboxfile...\n";
open(MBOX, $mboxfile);
while (<MBOX>) {
if ($blank && /^From /) {
if ($message) {
chop $message; # Remove extra blank line before next From
$response = $imap->append($mailbox, $message) if $count;
$count++;
}
$message = "";
}
else {
chop;
s/$/\r\n/; # IMAP requires CR/LF on each line
$message .= $_;
}
$blank = /^\r$/ ? 1 : 0;
}
$response = $imap->append($mailbox, $message) if $count;
$count++;
close(MBOX);
print "Transferred $count messages from $mboxfile to
$mailbox.\n";
}

sorry hab leider keine erfahrung damit, aber du bekommst das schon hin


ciao

bp
22.02.02, 11:58
also habe das script zum laufen gebracht, war etwas kompliziert denn man benötigt das NetxAP perl modul in der version 0.1 (bei SuSE 7.3 ist 0.2 mit dabei, damit geht es nicht) und das NetxAP benötigt dann noch weitere Perl module (Perl- Digest) also wenn man das alles berücksichtigt läuft auch das Script. Vielen Dank für den Tip! Hat mich weitergebracht.