I've hacked up a perl script to load a courier Maildir of mail into zimbra (some of our accounts have 20GB of mail which according to our quick calculation would take imapsync about a week to transfer (since the from server was loaded))...
What I don't know how to do is set those \Answered flags, the snippet of code that runs for each message (it's using expect to communicate with zmmailbox) is (note, perl not PHP but the PHP tag seemed to work OK):
PHP Code:
my $msgfile = "$dir/cur/$_";
my $msecs = (stat $msgfile)[9] * 1000;
$exp->send(qq{addMessage -d $msecs "$folder" "$msgfile"n});
$exp->expect(10, '-re', 'mbox.*?> \d+ ');
if ($exp->match()=~/mbox.*?> (\d+)/) {
my $mid = $1;
# .D. - this is a 'draft' message
# .R. - this message has been replied to
# .S. - this message has been viewed (seen)
# .T. - this message has been marked to be deleted (trashed)
# .F. - this message has been marked by the user, for some purpose.
if ($msgfile=~/.*:2,(.+)/) {
my $tags = $1;
my %tags;
for my $tag (split //, $tags) {
$tags{$tag} = 1;
}
if ($tags{'D'}) {
print MISSED "$mid\tdraft\n";
}
if ($tags{'R'}) {
print MISSED "$mid\treplied\n";
}
if ($tags{'S'}) {
$exp->send("markMessageRead $mid 1\n");
$exp->expect(10,'-re',"mbox.*>");
} else {
$exp->send("markMessageRead $mid 0\n");
$exp->expect(10,'-re',"mbox.*>");
}
if ($tags{'T'}) {
print MISSED "$mid\ttrash\n";
}
if ($tags{'F'}) {
$exp->send("flagMessage $mid 1\n");
$exp->expect(10,'-re',"mbox.*>");
} else {
$exp->send("flagMessage $mid 0\n");
$exp->expect(10,'-re',"mbox.*>");
}
}
}
Is there a zmmailbox command I can use to set the \Answered flags?