This commit is contained in:
Nick Bebout 2011-03-12 02:44:12 +00:00
parent c7f1a38411
commit ce5693f206
7 changed files with 216 additions and 15 deletions

14
CREDITS
View file

@ -1,5 +1,17 @@
#!/bin/cat
Harald A. Irmer
Huge migration with mbox format pb.
Several problems.
Aleksandar Milivojevic
Had problems with the flags arrays
Paul Dekkers
Had a problem with perl on freebsd.
Had memory problems solved by memory added.
Suggested --regexmess too, too late :-)
Jean-Michel besnard
Pb with woody, Mail::ImapClient and fetch_hash
@ -31,6 +43,8 @@ Gave "Domino IMAP4 Server Release 5.0.6"
UW "IMAP4rev1 2003.338rh"
Reed Sandberg
Gave "MDaemon 7.0.1 ---> courier-imap-2.2.1"
Gave the imapsync-undef_arrayref.diff patch.
Added and wrote option --foldersizes
Christoph Nagelreiter

View file

@ -1,15 +1,25 @@
RCS file: RCS/imapsync,v
Working file: imapsync
head: 1.118
head: 1.120
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 118; selected revisions: 118
total revisions: 120; selected revisions: 120
description:
----------------------------
revision 1.120
date: 2005/02/01 02:38:38; author: gilles; state: Exp; lines: +7 -6
Success stories : MDaemon
----------------------------
revision 1.119
date: 2005/02/01 01:54:08; author: gilles; state: Exp; lines: +13 -8
Fixed undef flag array problem (that I've never encounter).
Don't remenber who gave the patch
patches/imapsync-undef_arrayref.diff
----------------------------
revision 1.118
date: 2005/01/17 14:45:25; author: gilles; state: Exp; lines: +10 -8
--regexmess option can be repeated

7
README
View file

@ -2,7 +2,7 @@ NAME
imapsync - IMAP synchronization, copy or migration tool. Synchronize
mailboxes between two imap servers. Good at IMAP migration.
$Revision: 1.118 $
$Revision: 1.120 $
INSTALL
imapsync works fine under any Unix OS.
@ -163,7 +163,7 @@ IMAP SERVERS
- BincImap 1.2.3
- CommunicatePro server (Redhat 8.0)
- Courier IMAP 1.5.1, 2.2.0, 2.1.1
- Courier IMAP 1.5.1, 2.2.0, 2.1.1, 2.2.1
- Critical Path (7.0.020)
- Cyrus IMAP 1.5, 1.6, 2.1, 2.1.15, 2.1.16, 2.2.1, Cyrus 2.2.2-BETA.
- DBMail 1.2.1
@ -171,6 +171,7 @@ IMAP SERVERS
- Domino (Notes) 6.5, 5.0.6
- iPlanet Messaging server 4.15, 5.1
- IMail 7.15 (Ipswitch/Win2003), 8.12
- MDaemon 7.0.1
- MS Exchange Server 5.5
- Netscape Mail Server 3.6 (Wintel !)
- OpenWave
@ -239,5 +240,5 @@ AUTHOR
teaching free open and gratis softwares. Don't hesitate to pay him for
that services.
$Id: imapsync,v 1.118 2005/01/17 14:45:25 gilles Exp $
$Id: imapsync,v 1.120 2005/02/01 02:38:38 gilles Exp $

View file

@ -1 +1 @@
1.118
1.120

View file

@ -6,7 +6,7 @@ imapsync - IMAP synchronization, copy or migration
tool. Synchronize mailboxes between two imap servers. Good
at IMAP migration.
$Revision: 1.118 $
$Revision: 1.120 $
=head1 INSTALL
@ -188,7 +188,7 @@ Success stories reported (softwares in alphabetic order) :
- BincImap 1.2.3
- CommunicatePro server (Redhat 8.0)
- Courier IMAP 1.5.1, 2.2.0, 2.1.1
- Courier IMAP 1.5.1, 2.2.0, 2.1.1, 2.2.1
- Critical Path (7.0.020)
- Cyrus IMAP 1.5, 1.6, 2.1, 2.1.15, 2.1.16, 2.2.1, Cyrus 2.2.2-BETA.
- DBMail 1.2.1
@ -196,6 +196,7 @@ Success stories reported (softwares in alphabetic order) :
- Domino (Notes) 6.5, 5.0.6
- iPlanet Messaging server 4.15, 5.1
- IMail 7.15 (Ipswitch/Win2003), 8.12
- MDaemon 7.0.1
- MS Exchange Server 5.5
- Netscape Mail Server 3.6 (Wintel !)
- OpenWave
@ -281,7 +282,7 @@ Gilles LAMIRAL earn his living writing, installing,
configuring and teaching free open and gratis
softwares. Don't hesitate to pay him for that services.
$Id: imapsync,v 1.118 2005/01/17 14:45:25 gilles Exp $
$Id: imapsync,v 1.120 2005/02/01 02:38:38 gilles Exp $
=cut
@ -324,7 +325,7 @@ my(
use vars qw ($opt_G); # missing code for this will be option.
$rcs = ' $Id: imapsync,v 1.118 2005/01/17 14:45:25 gilles Exp $ ';
$rcs = ' $Id: imapsync,v 1.120 2005/02/01 02:38:38 gilles Exp $ ';
$rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN";
@ -361,8 +362,8 @@ $error=0;
my $banner = join("",
'$RCSfile: imapsync,v $ ',
'$Revision: 1.118 $ ',
'$Date: 2005/01/17 14:45:25 $ ',
'$Revision: 1.120 $ ',
'$Date: 2005/02/01 02:38:38 $ ',
"\n",
"Mail::IMAPClient version used here is ",
$VERSION_IMAPClient, " auth md5 : $md5_supported",
@ -801,6 +802,7 @@ FOLDER: foreach my $f_fold (@f_folders) {
}
my $flags_f = join(" ", @{$from->flags($f_msg)});
# RFC 2060 : This flag can not be altered by the client
$flags_f =~ s@\\Recent@@g;
@ -837,13 +839,17 @@ FOLDER: foreach my $f_fold (@f_folders) {
$debug and print "Setting flags\n";
my (@flags_f,@flags_t);
@flags_f = @{$from->flags($f_msg)};
my $flags_f_rv = $from->flags($f_msg);
@flags_f = @{$flags_f_rv} if ref($flags_f_rv);
# No flag \Recent here, no ?
$to->store($t_msg,
"+FLAGS (" . join(" ", @flags_f) . ")"
) unless ($dry) ;
@flags_t = @{$to->flags($t_msg)};
my $flags_t_rv = $to->flags($t_msg);
@flags_t = @{$flags_t_rv} if ref($flags_t_rv);
$debug and print
"flags from : @flags_f\n",
"flags to : @flags_t\n";

108
patches/imapsync-ssl2.diff Normal file
View file

@ -0,0 +1,108 @@
--- /tmp/imapsync-1.118 2005-01-21 09:24:18.915332630 -0800
+++ imapsync 2005-01-21 13:38:57.842421835 -0800
@@ -34,9 +34,9 @@
imapsync --help
imapsync
- imapsync [--host1 server1] [--port1 <num>]
+ imapsync [--host1 server1] [--port1 <num>] [--ssl1]
[--user1 <string>] [--passfile1 <string>]
- [--host2 server2] [--port2 <num>]
+ [--host2 server2] [--port2 <num>] [--ssl2]
[--user2 <string>] [--passfile2 <string>]
[--folder <string> --folder <string> ...]
[--include <regex>] [--exclude <regex>]
@@ -292,13 +292,15 @@
use Mail::IMAPClient;
use Digest::MD5 qw(md5_base64);
#use Digest::HMAC_MD5;
+use IO::Socket::INET;
+use IO::Socket::SSL;
eval { require 'usr/include/sysexits.ph' };
my(
$rcs, $debug, $debugimap, $error,
- $host1, $host2, $port1, $port2,
+ $host1, $host2, $port1, $port2, $ssl1, $ssl2,
$user1, $user2, $password1, $password2, $passfile1, $passfile2,
@folder, $include, $exclude, $prefix2, $regextrans2, @regexmess,
$sep1, $sep2,
@@ -383,13 +385,13 @@
}
$host1 || missing_option("--host1") ;
-$port1 = (defined($port1)) ? $port1 : 143;
+$port1 = (defined($port1)) ? $port1 : ((defined($ssl1)) ? 993 : 143);
$user1 || missing_option("--user1");
$password1 || $passfile1 || missing_option("--passfile1 or --password1");
$password1 = (defined($passfile1)) ? firstline ($passfile1) : $password1;
$host2 || missing_option("--host2") ;
-$port2 = (defined($port2)) ? $port2 : 143;
+$port2 = (defined($port2)) ? $port2 : ((defined($ssl2)) ? 993 : 143);
$user2 || missing_option("--user2");
$password2 || $passfile2 || missing_option("--passfile2 or --password2");
$password2 = (defined($passfile2)) ? firstline ($passfile2) : $password2;
@@ -417,17 +419,35 @@
$timebefore = $timestart;
$debugimap and print "From connection\n";
-$from = login_imap($host1, $port1, $user1, $password1, $debugimap, $timeout);
+$from = login_imap($host1, $port1, $user1, $password1, $debugimap, $timeout, $ssl1);
$debugimap and print "To connection\n";
-$to = login_imap($host2, $port2, $user2, $password2, $debugimap, $timeout);
+$to = login_imap($host2, $port2, $user2, $password2, $debugimap, $timeout, $ssl2);
sub login_imap {
my($host, $port, $user, $password,
- $debugimap, $timeout, $authmech) = @_;
- my $imap = Mail::IMAPClient->new();
- $imap->Server($host);
- $imap->Port($port);
+ $debugimap, $timeout, $authmech, $ssl) = @_;
+ my $socket = undef;
+
+ if (!defined($ssl)) {
+ $socket = IO::Socket::INET->new( PeerAddr => $host,
+ PeerPort => $port,
+ Proto => 'tcp');
+ } else {
+ $socket = IO::Socket::SSL->new( PeerAddr => $host,
+ PeerPort => $port,
+ Proto => 'tcp');
+ }
+ if (!$socket) {
+ die "Can not open imap connection on [$host:$port]: $@";
+ }
+
+ my $imap = Mail::IMAPClient->new(Server => $host,
+ Port => $port,
+ Socket => $socket,
+ User => $user,
+ Password=> $password);
+ $imap->State($imap->Connected());
$imap->Fast_io(1);
$imap->Buffer(65536);
$imap->Uid(1);
@@ -440,9 +460,6 @@
$imap->Timeout($timeout);
print "Setting imap timeout to $timeout\n";
}
-
- $imap->User($user);
- $imap->Password($password);
md5auth($imap);
$imap->login() or die "Error login : [$host] with user [$user] : $@";
return($imap);
@@ -918,6 +935,8 @@
"host2=s" => \$host2,
"port1=i" => \$port1,
"port2=i" => \$port2,
+ "ssl1!" => \$ssl1,
+ "ssl2!" => \$ssl2,
"user1=s" => \$user1,
"user2=s" => \$user2,
"password1=s" => \$password1,

View file

@ -0,0 +1,62 @@
--- imapsync Mon Oct 18 21:15:27 2004
+++ imapsync-mod Sat Nov 20 15:15:52 2004
@@ -552,7 +552,7 @@
my $tmess = 0;
print "Calculating sizes...\n";
foreach my $f_fold (@f_folders) {
- print "From Folder [$f_fold]\n";
+ print "\nFrom Folder [$f_fold]\n";
my $stot = 0;
my $smess = 0;
unless ($from->select($f_fold)) {
@@ -574,7 +574,6 @@
$stot += $s;
print ".";
}
- print "\n";
print "Size of $f_fold: $stot\n";
print "Messages in $f_fold: $smess\n";
$tot += $stot;
@@ -589,11 +588,12 @@
map {$stot2 += $hashref->{$_}->{"RFC822.SIZE"}} keys %$hashref;
}
print "Size of $f_fold: $stot2\n";
+ print "Messages in $f_fold: $smess2\n";
$tot += $stot2;
$tmess += $smess2;
}
}
- print "Total size: $tot\n";
+ print "\n\nTotal size: $tot\n";
print "Total messages: $tmess\n";
print "Time : ", timenext(), " s\n";
@@ -746,7 +746,9 @@
$d = "\"$d\"";
$debug and print "internal date from 1: [$d]\n";
$syncinternaldates or $d = "";
- my $flags_f = join(" ", @{$from->flags($f_msg)});
+ my $flags_f_rv = $from->flags($f_msg);
+ my $flags_f = '';
+ $flags_f = join(" ", @{$flags_f_rv}) if ref($flags_f_rv);
# RFC 2060 : This flag can not be altered by the client
$flags_f =~ s@\\Recent@@g;
@@ -781,13 +783,15 @@
$debug and print "Setting flags\n";
my (@flags_f,@flags_t);
- @flags_f = @{$from->flags($f_msg)};
+ my $flags_f_rv = $from->flags($f_msg);
+ @flags_f = @{$flags_f_rv} if ref($flags_f_rv);
# No flag \Recent here, no ?
$to->store($t_msg,
"+FLAGS (" . join(" ", @flags_f) . ")"
);
- @flags_t = @{$to->flags($t_msg)};
+ my $flags_t_rv = $to->flags($t_msg);
+ @flags_t = @{$flags_t_rv} if ref($flags_t_rv);
$debug and print
"flags from : @flags_f\n",
"flags to : @flags_t\n";