mirror of
https://github.com/imapsync/imapsync.git
synced 2025-06-06 04:37:18 +02:00
1.261
This commit is contained in:
parent
f854c1ea0a
commit
bf62e181ca
6 changed files with 109 additions and 53 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,17 +1,23 @@
|
||||||
|
|
||||||
RCS file: RCS/imapsync,v
|
RCS file: RCS/imapsync,v
|
||||||
Working file: imapsync
|
Working file: imapsync
|
||||||
head: 1.260
|
head: 1.261
|
||||||
branch:
|
branch:
|
||||||
locks: strict
|
locks: strict
|
||||||
gilles: 1.260
|
gilles: 1.261
|
||||||
access list:
|
access list:
|
||||||
symbolic names:
|
symbolic names:
|
||||||
keyword substitution: kv
|
keyword substitution: kv
|
||||||
total revisions: 260; selected revisions: 260
|
total revisions: 261; selected revisions: 261
|
||||||
description:
|
description:
|
||||||
----------------------------
|
----------------------------
|
||||||
revision 1.260 locked by: gilles;
|
revision 1.261 locked by: gilles;
|
||||||
|
date: 2008/08/16 15:56:00; author: gilles; state: Exp; lines: +32 -41
|
||||||
|
- Fixed bug about ssl and justconnect option
|
||||||
|
- Cleaned connect code.
|
||||||
|
- Started gmail support.
|
||||||
|
----------------------------
|
||||||
|
revision 1.260
|
||||||
date: 2008/08/13 03:14:14; author: gilles; state: Exp; lines: +54 -13
|
date: 2008/08/13 03:14:14; author: gilles; state: Exp; lines: +54 -13
|
||||||
- Added option --idatefromheader :
|
- Added option --idatefromheader :
|
||||||
sets the internal dates on host2 same as the "Date:" headers.
|
sets the internal dates on host2 same as the "Date:" headers.
|
||||||
|
|
25
FAQ
25
FAQ
|
@ -214,9 +214,9 @@ c) or use stunnel on inetd
|
||||||
imaps stream tcp nowait cyrus /usr/sbin/stunnel -s cyrus -p /etc/ssl/certs/imapd.pem -r localhost:imap2
|
imaps stream tcp nowait cyrus /usr/sbin/stunnel -s cyrus -p /etc/ssl/certs/imapd.pem -r localhost:imap2
|
||||||
|
|
||||||
=======================================================================
|
=======================================================================
|
||||||
Q: I'm trying to use imapsync for gmail, but it requires ssl, or at least
|
Q: I'm trying to use imapsync on win32 for gmail, but it requires ssl,
|
||||||
claims to. Imapsync appears to require io-socket-ssl, which doesn't seem
|
or at least claims to. Imapsync appears to require io-socket-ssl,
|
||||||
to be available on win32. Are there any other options?
|
which doesn't seem to be available on win32. Are there any other options?
|
||||||
|
|
||||||
R: (Q and R come as is from Bryce Walter)
|
R: (Q and R come as is from Bryce Walter)
|
||||||
I think I'm having success using cygwin perl instead of
|
I think I'm having success using cygwin perl instead of
|
||||||
|
@ -512,7 +512,6 @@ imapsync --syncinternaldates \
|
||||||
--user1 my_email@oldhost.com \
|
--user1 my_email@oldhost.com \
|
||||||
--password1 password \
|
--password1 password \
|
||||||
--host2 imap.gmail.com --port2 993 --ssl2 \
|
--host2 imap.gmail.com --port2 993 --ssl2 \
|
||||||
--authmech2 LOGIN \
|
|
||||||
--user2 my_email@gmail.com \
|
--user2 my_email@gmail.com \
|
||||||
--password2 password \
|
--password2 password \
|
||||||
--prefix2 '[Gmail]/' \
|
--prefix2 '[Gmail]/' \
|
||||||
|
@ -521,6 +520,24 @@ imapsync --syncinternaldates \
|
||||||
|
|
||||||
The same goes for the "All Mail" archive psuedo-folder.
|
The same goes for the "All Mail" archive psuedo-folder.
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
Q. Synchronysing from Gmail to XXX
|
||||||
|
|
||||||
|
R. Gmail needs ssl.
|
||||||
|
|
||||||
|
./imapsync \
|
||||||
|
--host1 imap.gmail.com --ssl1 \
|
||||||
|
--user1 gilles.lamiral@gmail.com \
|
||||||
|
--passfile1 /var/tmp/secret.gilles_gmail \
|
||||||
|
--host2 localhost
|
||||||
|
--user2 tata@est.belle \
|
||||||
|
--passfile2 /var/tmp/secret.tata \
|
||||||
|
--useheader 'Message-Id' --skipsize
|
||||||
|
|
||||||
|
If your destination imap server doesn't like "[Gmail]" name, just add
|
||||||
|
option:
|
||||||
|
--regextrans2 's/\[Gmail\]/Gmail/'
|
||||||
|
|
||||||
|
|
||||||
=======================================================================
|
=======================================================================
|
||||||
Q. I'm migrating from WU to Cyrus, and the mail folders are
|
Q. I'm migrating from WU to Cyrus, and the mail folders are
|
||||||
|
|
4
README
4
README
|
@ -3,7 +3,7 @@ NAME
|
||||||
Synchronise mailboxes between two imap servers. Good at IMAP migration.
|
Synchronise mailboxes between two imap servers. Good at IMAP migration.
|
||||||
More than 32 different IMAP server softwares supported with success.
|
More than 32 different IMAP server softwares supported with success.
|
||||||
|
|
||||||
$Revision: 1.260 $
|
$Revision: 1.261 $
|
||||||
|
|
||||||
INSTALL
|
INSTALL
|
||||||
imapsync works fine under any Unix OS with perl.
|
imapsync works fine under any Unix OS with perl.
|
||||||
|
@ -364,5 +364,5 @@ SIMILAR SOFTWARES
|
||||||
|
|
||||||
Feedback (good or bad) will be always welcome.
|
Feedback (good or bad) will be always welcome.
|
||||||
|
|
||||||
$Id: imapsync,v 1.260 2008/08/13 03:14:14 gilles Exp gilles $
|
$Id: imapsync,v 1.261 2008/08/16 15:56:00 gilles Exp gilles $
|
||||||
|
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
1.260
|
1.261
|
||||||
|
|
67
imapsync
67
imapsync
|
@ -9,7 +9,7 @@ tool. Synchronise mailboxes between two imap servers. Good
|
||||||
at IMAP migration. More than 32 different IMAP server softwares
|
at IMAP migration. More than 32 different IMAP server softwares
|
||||||
supported with success.
|
supported with success.
|
||||||
|
|
||||||
$Revision: 1.260 $
|
$Revision: 1.261 $
|
||||||
|
|
||||||
=head1 INSTALL
|
=head1 INSTALL
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ Entries for imapsync:
|
||||||
|
|
||||||
Feedback (good or bad) will be always welcome.
|
Feedback (good or bad) will be always welcome.
|
||||||
|
|
||||||
$Id: imapsync,v 1.260 2008/08/13 03:14:14 gilles Exp gilles $
|
$Id: imapsync,v 1.261 2008/08/16 15:56:00 gilles Exp gilles $
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ my(
|
||||||
use vars qw ($opt_G); # missing code for this will be option.
|
use vars qw ($opt_G); # missing code for this will be option.
|
||||||
|
|
||||||
|
|
||||||
$rcs = '$Id: imapsync,v 1.260 2008/08/13 03:14:14 gilles Exp gilles $ ';
|
$rcs = '$Id: imapsync,v 1.261 2008/08/16 15:56:00 gilles Exp gilles $ ';
|
||||||
$rcs =~ m/,v (\d+\.\d+)/;
|
$rcs =~ m/,v (\d+\.\d+)/;
|
||||||
$VERSION = ($1) ? $1 : "UNKNOWN";
|
$VERSION = ($1) ? $1 : "UNKNOWN";
|
||||||
|
|
||||||
|
@ -523,8 +523,8 @@ $error=0;
|
||||||
|
|
||||||
my $banner = join("",
|
my $banner = join("",
|
||||||
'$RCSfile: imapsync,v $ ',
|
'$RCSfile: imapsync,v $ ',
|
||||||
'$Revision: 1.260 $ ',
|
'$Revision: 1.261 $ ',
|
||||||
'$Date: 2008/08/13 03:14:14 $ ',
|
'$Date: 2008/08/16 15:56:00 $ ',
|
||||||
"\n",localhost_info(),
|
"\n",localhost_info(),
|
||||||
" and the module Mail::IMAPClient version used here is ",
|
" and the module Mail::IMAPClient version used here is ",
|
||||||
$VERSION_IMAPClient,"\n",
|
$VERSION_IMAPClient,"\n",
|
||||||
|
@ -556,11 +556,12 @@ $host2 || missing_option("--host2") ;
|
||||||
$port2 ||= defined $ssl2 ? 993 : 143;
|
$port2 ||= defined $ssl2 ? 993 : 143;
|
||||||
|
|
||||||
sub connect_imap {
|
sub connect_imap {
|
||||||
my($host, $port, $debugimap) = @_;
|
my($host, $port, $debugimap, $ssl) = @_;
|
||||||
my $imap = Mail::IMAPClient->new();
|
my $imap = Mail::IMAPClient->new();
|
||||||
$imap->Server($host);
|
$imap->Server($host);
|
||||||
$imap->Port($port);
|
$imap->Port($port);
|
||||||
$imap->Debug($debugimap);
|
$imap->Debug($debugimap);
|
||||||
|
$imap->Ssl($ssl);
|
||||||
$imap->connect()
|
$imap->connect()
|
||||||
or die "Can not open imap connection on [$host] : $@\n";
|
or die "Can not open imap connection on [$host] : $@\n";
|
||||||
}
|
}
|
||||||
|
@ -583,10 +584,10 @@ if ($justconnect) {
|
||||||
my $from = ();
|
my $from = ();
|
||||||
my $to = ();
|
my $to = ();
|
||||||
|
|
||||||
$from = connect_imap($host1, $port1);
|
$from = connect_imap($host1, $port1, $debugimap, $ssl1);
|
||||||
print "From software : ", server_banner($from);
|
print "From software : ", server_banner($from);
|
||||||
print "From capability : ", join(" ", $from->capability()), "\n";
|
print "From capability : ", join(" ", $from->capability()), "\n";
|
||||||
$to = connect_imap($host2, $port2);
|
$to = connect_imap($host2, $port2, $debugimap, $ssl2);
|
||||||
print "To software : ", server_banner($to);
|
print "To software : ", server_banner($to);
|
||||||
print "To capability : ", join(" ", $to->capability()), "\n";
|
print "To capability : ", join(" ", $to->capability()), "\n";
|
||||||
$from->logout();
|
$from->logout();
|
||||||
|
@ -711,20 +712,10 @@ sub login_imap {
|
||||||
$debugimap, $timeout, $fastio,
|
$debugimap, $timeout, $fastio,
|
||||||
$ssl, $authmech, $authuser) = @_;
|
$ssl, $authmech, $authuser) = @_;
|
||||||
my ($imap);
|
my ($imap);
|
||||||
if ($ssl) {
|
|
||||||
require IO::Socket::SSL;
|
|
||||||
my $socssl = new IO::Socket::SSL("$host:$port");
|
|
||||||
die "Error connecting to $host:$port: $@\n" unless $socssl;
|
|
||||||
$socssl->autoflush(1);
|
|
||||||
|
|
||||||
$imap = Mail::IMAPClient->new(
|
|
||||||
Socket => $socssl,
|
|
||||||
Server => $host,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$imap = Mail::IMAPClient->new();
|
$imap = Mail::IMAPClient->new();
|
||||||
}
|
|
||||||
|
$imap->Ssl($ssl);
|
||||||
$imap->Clear(20);
|
$imap->Clear(20);
|
||||||
$imap->Server($host);
|
$imap->Server($host);
|
||||||
$imap->Port($port);
|
$imap->Port($port);
|
||||||
|
@ -735,13 +726,9 @@ sub login_imap {
|
||||||
$imap->Debug($debugimap);
|
$imap->Debug($debugimap);
|
||||||
$timeout and $imap->Timeout($timeout);
|
$timeout and $imap->Timeout($timeout);
|
||||||
|
|
||||||
if ($ssl) {
|
|
||||||
$imap->State(Mail::IMAPClient::Connected);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$imap->connect()
|
$imap->connect()
|
||||||
or die "Can not open imap connection on [$host] with user [$user] : $@\n";
|
or die "Can not open imap connection on [$host] with user [$user] : $@\n";
|
||||||
}
|
|
||||||
print "Banner : ", server_banner($imap);
|
print "Banner : ", server_banner($imap);
|
||||||
|
|
||||||
if ($imap->has_capability("AUTH=$authmech")
|
if ($imap->has_capability("AUTH=$authmech")
|
||||||
|
@ -1100,7 +1087,7 @@ sub foldersizes {
|
||||||
warn
|
warn
|
||||||
"$side Folder $folder : Could not select ",
|
"$side Folder $folder : Could not select ",
|
||||||
$imap->LastError, "\n";
|
$imap->LastError, "\n";
|
||||||
$error++;
|
#$error++;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if (defined($maxage) or defined($minage)) {
|
if (defined($maxage) or defined($minage)) {
|
||||||
|
@ -1259,7 +1246,7 @@ FOLDER: foreach my $f_fold (@f_folders) {
|
||||||
warn
|
warn
|
||||||
"From Folder $f_fold : Could not select ",
|
"From Folder $f_fold : Could not select ",
|
||||||
$from->LastError, "\n";
|
$from->LastError, "\n";
|
||||||
$error++;
|
#$error++;
|
||||||
next FOLDER;
|
next FOLDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1285,7 +1272,7 @@ FOLDER: foreach my $f_fold (@f_folders) {
|
||||||
warn
|
warn
|
||||||
"To Folder $t_fold : Could not select ",
|
"To Folder $t_fold : Could not select ",
|
||||||
$to->LastError, "\n";
|
$to->LastError, "\n";
|
||||||
$error++;
|
#$error++;
|
||||||
next FOLDER;
|
next FOLDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2462,6 +2449,7 @@ use constant NonFolderArg => 1; # Value to pass to Massage to
|
||||||
|
|
||||||
until ($code) {
|
until ($code) {
|
||||||
$output = $self->_read_line or return undef;
|
$output = $self->_read_line or return undef;
|
||||||
|
|
||||||
foreach my $o (@$output) {
|
foreach my $o (@$output) {
|
||||||
$self->_record($count,$o); # $o is a ref
|
$self->_record($count,$o); # $o is a ref
|
||||||
($code) = $o->[DATA] =~ /^\+(.*)$/ ;
|
($code) = $o->[DATA] =~ /^\+(.*)$/ ;
|
||||||
|
@ -2469,10 +2457,11 @@ use constant NonFolderArg => 1; # Value to pass to Massage to
|
||||||
$self->State(Unconnected);
|
$self->State(Unconnected);
|
||||||
return undef ;
|
return undef ;
|
||||||
}
|
}
|
||||||
|
if ($o->[DATA]=~ /^\d+\s+(NO|BAD)/i) {
|
||||||
|
return undef ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef if $code =~ /^BAD|^NO/ ;
|
|
||||||
|
|
||||||
if ('CRAM-MD5' eq $scheme && ! $response) {
|
if ('CRAM-MD5' eq $scheme && ! $response) {
|
||||||
if ($Mail::IMAPClient::_CRAM_MD5_ERR) {
|
if ($Mail::IMAPClient::_CRAM_MD5_ERR) {
|
||||||
|
@ -2559,6 +2548,12 @@ use constant NonFolderArg => 1; # Value to pass to Massage to
|
||||||
return $string;
|
return $string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
*Mail::IMAPClient::Ssl = sub {
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
if (@_) { $self->{SSL} = shift }
|
||||||
|
return $self->{SSL};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
*Mail::IMAPClient::connect = sub {
|
*Mail::IMAPClient::connect = sub {
|
||||||
|
@ -2569,9 +2564,10 @@ use constant NonFolderArg => 1; # Value to pass to Massage to
|
||||||
and $IO::Socket::INET::VERSION eq '1.25'
|
and $IO::Socket::INET::VERSION eq '1.25'
|
||||||
and !$self->Port;
|
and !$self->Port;
|
||||||
%$self = (%$self, @_);
|
%$self = (%$self, @_);
|
||||||
my $sock = IO::Socket::INET->new;
|
|
||||||
my $dp = 'imap(143)';
|
my $sock = ($self->Ssl ? IO::Socket::SSL->new : IO::Socket::INET->new);
|
||||||
#print "i01\n";
|
my $dp = ($self->Ssl ? 'imaps(993)' : 'imap(143)');
|
||||||
|
|
||||||
my $ret = $sock->configure({
|
my $ret = $sock->configure({
|
||||||
PeerAddr => $self->Server ,
|
PeerAddr => $self->Server ,
|
||||||
PeerPort => $self->Port||$dp ,
|
PeerPort => $self->Port||$dp ,
|
||||||
|
@ -2579,7 +2575,6 @@ use constant NonFolderArg => 1; # Value to pass to Massage to
|
||||||
Timeout => $self->Timeout||0 ,
|
Timeout => $self->Timeout||0 ,
|
||||||
Debug => $self->Debug ,
|
Debug => $self->Debug ,
|
||||||
});
|
});
|
||||||
#print "i02\n";
|
|
||||||
unless ( defined($ret) ) {
|
unless ( defined($ret) ) {
|
||||||
$self->LastError( "$@\n");
|
$self->LastError( "$@\n");
|
||||||
$@ = "$@";
|
$@ = "$@";
|
||||||
|
@ -2587,19 +2582,15 @@ use constant NonFolderArg => 1; # Value to pass to Massage to
|
||||||
unless defined wantarray;
|
unless defined wantarray;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
#print "i03\n";
|
|
||||||
$self->Socket($sock);
|
$self->Socket($sock);
|
||||||
$self->State(Connected);
|
$self->State(Connected);
|
||||||
#print "i04\n";
|
|
||||||
$sock->autoflush(1) ;
|
$sock->autoflush(1) ;
|
||||||
|
|
||||||
my ($code, $output);
|
my ($code, $output);
|
||||||
$output = "";
|
$output = "";
|
||||||
#print "i05\n";
|
|
||||||
until ( $code ) {
|
until ( $code ) {
|
||||||
|
|
||||||
$output = $self->_read_line or return undef;
|
$output = $self->_read_line or return undef;
|
||||||
#print "i06\n";
|
|
||||||
for my $o (@$output) {
|
for my $o (@$output) {
|
||||||
$self->_debug("Connect: Received this from readline: " .
|
$self->_debug("Connect: Received this from readline: " .
|
||||||
join("/",@$o) . "\n");
|
join("/",@$o) . "\n");
|
||||||
|
|
44
tests.sh
44
tests.sh
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# $Id: tests.sh,v 1.77 2008/08/13 23:33:18 gilles Exp gilles $
|
# $Id: tests.sh,v 1.78 2008/08/16 15:54:40 gilles Exp gilles $
|
||||||
|
|
||||||
#### Shell pragmas
|
#### Shell pragmas
|
||||||
|
|
||||||
|
@ -648,6 +648,20 @@ ll_regex_flag()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ssl_justconnect() {
|
||||||
|
if test X`hostname` = X"plume"; then
|
||||||
|
echo3 Here is plume
|
||||||
|
$CMD_PERL ./imapsync \
|
||||||
|
--host1 localhost \
|
||||||
|
--host2 localhost \
|
||||||
|
--ssl1 --ssl2 \
|
||||||
|
--justconnect
|
||||||
|
else
|
||||||
|
:
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ll_ssl() {
|
ll_ssl() {
|
||||||
if test X`hostname` = X"plume"; then
|
if test X`hostname` = X"plume"; then
|
||||||
echo3 Here is plume
|
echo3 Here is plume
|
||||||
|
@ -756,6 +770,8 @@ ll_bigmail() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
msw() {
|
msw() {
|
||||||
sendtestmessage toto@est.belle
|
sendtestmessage toto@est.belle
|
||||||
scp imapsync Admin@192.168.68.77:'C:/msys/1.0/home/Admin/imapsync/imapsync'
|
scp imapsync Admin@192.168.68.77:'C:/msys/1.0/home/Admin/imapsync/imapsync'
|
||||||
|
@ -764,6 +780,30 @@ msw() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
gmail() {
|
||||||
|
if test X`hostname` = X"plume"; then
|
||||||
|
echo3 Here is plume
|
||||||
|
$CMD_PERL ./imapsync \
|
||||||
|
--host1 imap.gmail.com \
|
||||||
|
--ssl1 \
|
||||||
|
--user1 gilles.lamiral@gmail.com \
|
||||||
|
--passfile1 /var/tmp/secret.gilles_gmail \
|
||||||
|
--host2 localhost \
|
||||||
|
--ssl2 \
|
||||||
|
--user2 tata@est.belle \
|
||||||
|
--passfile2 /var/tmp/secret.tata \
|
||||||
|
--useheader 'Message-Id' --skipsize \
|
||||||
|
--regextrans2 's/\[Gmail\]/Gmail/' \
|
||||||
|
#--dry # --debug --debugimap # --authmech1 LOGIN
|
||||||
|
|
||||||
|
else
|
||||||
|
:
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# specific tests
|
# specific tests
|
||||||
##########################
|
##########################
|
||||||
|
@ -1033,6 +1073,8 @@ test $# -eq 0 && run_tests \
|
||||||
ll_delete2 \
|
ll_delete2 \
|
||||||
ll_folderrec \
|
ll_folderrec \
|
||||||
ll_bigmail \
|
ll_bigmail \
|
||||||
|
gmail \
|
||||||
|
ssl_justconnect \
|
||||||
# msw
|
# msw
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue