This commit is contained in:
Nick Bebout 2011-03-12 02:43:45 +00:00
parent dcd74bf3e7
commit ae427983f8
5 changed files with 64 additions and 25 deletions

View file

@ -1,15 +1,38 @@
RCS file: RCS/imapsync,v RCS file: RCS/imapsync,v
Working file: imapsync Working file: imapsync
head: 1.15 head: 1.20
branch: branch:
locks: strict locks: strict
access list: access list:
symbolic names: symbolic names:
keyword substitution: kv keyword substitution: kv
total revisions: 15; selected revisions: 15 total revisions: 20; selected revisions: 20
description: description:
---------------------------- ----------------------------
revision 1.20
date: 2003/08/21 16:31:53; author: gilles; state: Exp; lines: +6 -5
Fixed banner output. Must be after getoptions because of --version
----------------------------
revision 1.19
date: 2003/08/21 16:18:32; author: gilles; state: Exp; lines: +11 -8
Added code and comment to understand why message uid was not printed
Solution : some imap server don't have UIDPLIS Capability
----------------------------
revision 1.18
date: 2003/08/21 14:37:45; author: gilles; state: Exp; lines: +5 -5
Removed unuseful param in $from->folders call
----------------------------
revision 1.17
date: 2003/08/21 13:49:05; author: gilles; state: Exp; lines: +5 -4
Fixed banner
----------------------------
revision 1.16
date: 2003/08/21 13:47:14; author: gilles; state: Exp; lines: +12 -11
Added imapxfer url, thanks to Daniele Frijia.
Added [] to see blank caracter in folder names.
Added a banner with imapsync version.
----------------------------
revision 1.15 revision 1.15
date: 2003/07/17 12:22:23; author: gilles; state: Exp; lines: +4 -4 date: 2003/07/17 12:22:23; author: gilles; state: Exp; lines: +4 -4
Added imap debug mode to server2 Added imap debug mode to server2

9
README
View file

@ -1,7 +1,7 @@
NAME NAME
imapsync - synchronize mailboxes between two imap servers. imapsync - synchronize mailboxes between two imap servers.
$Revision: 1.15 $ $Revision: 1.20 $
INSTALL INSTALL
Get imapsync at http://www.linux-france.org/prj/imapsync/dist/ Get imapsync at http://www.linux-france.org/prj/imapsync/dist/
@ -110,9 +110,10 @@ IMAP SERVERS
SIMILAR SOFTWARES SIMILAR SOFTWARES
offlineimap : http://gopher.quux.org:70/devel/offlineimap/ offlineimap : http://gopher.quux.org:70/devel/offlineimap/
mailsync : http://mailsync.sourceforge.net/ mailsync : http://mailsync.sourceforge.net/
imapxfer : ? imapxfer : http://www.washington.edu/imap/
part of the imap-utils from UW.
Feedback will be welcome. Feedback (good or bad) will be always welcome.
$Id: imapsync,v 1.15 2003/07/17 12:22:23 gilles Exp $ $Id: imapsync,v 1.20 2003/08/21 16:31:53 gilles Exp $

View file

@ -1 +1 @@
1.15 1.20

View file

@ -4,7 +4,7 @@
imapsync - synchronize mailboxes between two imap servers. imapsync - synchronize mailboxes between two imap servers.
$Revision: 1.15 $ $Revision: 1.20 $
=head1 INSTALL =head1 INSTALL
@ -132,11 +132,12 @@ both sides. This will help future users.
offlineimap : http://gopher.quux.org:70/devel/offlineimap/ offlineimap : http://gopher.quux.org:70/devel/offlineimap/
mailsync : http://mailsync.sourceforge.net/ mailsync : http://mailsync.sourceforge.net/
imapxfer : ? imapxfer : http://www.washington.edu/imap/
part of the imap-utils from UW.
Feedback will be welcome. Feedback (good or bad) will be always welcome.
$Id: imapsync,v 1.15 2003/07/17 12:22:23 gilles Exp $ $Id: imapsync,v 1.20 2003/08/21 16:31:53 gilles Exp $
=cut =cut
@ -147,7 +148,6 @@ use Getopt::Long;
use Mail::IMAPClient; use Mail::IMAPClient;
use Digest::MD5 qw(md5_base64); use Digest::MD5 qw(md5_base64);
my( my(
$rcs, $debug, $debugimap, $error, $rcs, $debug, $debugimap, $error,
$host1, $host2, $port1, $port2, $host1, $host2, $port1, $port2,
@ -155,18 +155,21 @@ my(
@folder, @folder,
$delete, $expunge, $dry, $delete, $expunge, $dry,
$version, $VERSION, $help, $version, $VERSION, $help,
); );
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.15 2003/07/17 12:22:23 gilles Exp $ '; $rcs = ' $Id: imapsync,v 1.20 2003/08/21 16:31:53 gilles Exp $ ';
$rcs =~ m/,v (\d+\.\d+)/; $rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN"; $VERSION = ($1) ? $1 : "UNKNOWN";
$error=0; $error=0;
my $banner = '$RCSfile: imapsync,v $ ' . '$Revision: 1.20 $ ' . '$Date: 2003/08/21 16:31:53 $ ' . "\n";
get_options(); get_options();
print $banner;
sub missing_option { sub missing_option {
my ($option) = @_; my ($option) = @_;
@ -224,7 +227,7 @@ my $t_sep = $to->namespace()->[0][0][1];
if (scalar(@folder)) { if (scalar(@folder)) {
# folders are given as argument. # folders are given as argument.
foreach my $f_fold (@folder) { foreach my $f_fold (@folder) {
push (@f_folders, @{$from->folders("$f_fold", ".")}); push (@f_folders, @{$from->folders($f_fold)});
} }
}else{ }else{
# no folder given so select all # no folder given so select all
@ -237,14 +240,14 @@ print "From folders : @f_folders\n";
FOLDER: foreach my $f_fold (@f_folders) { FOLDER: foreach my $f_fold (@f_folders) {
my $t_fold; my $t_fold;
print "From Folder $f_fold\n"; print "From Folder [$f_fold]\n";
# unless ($f_fold =~ m/^INBOX/) { # unless ($f_fold =~ m/^INBOX/) {
# $t_fold = "INBOX." . $f_fold; # $t_fold = "INBOX." . $f_fold;
# }else { # }else {
$t_fold = $f_fold; $t_fold = $f_fold;
# } # }
$t_fold =~ s@\$f_sep@\$t_sep@g; $t_fold =~ s@\$f_sep@\$t_sep@g;
print "To Folder $t_fold\n"; print "To Folder [$t_fold]\n";
unless ($from->select($f_fold)) { unless ($from->select($f_fold)) {
warn warn
"From Folder $f_fold : Could not select ", "From Folder $f_fold : Could not select ",
@ -254,10 +257,10 @@ FOLDER: foreach my $f_fold (@f_folders) {
} }
unless ($to->exists($t_fold)) { unless ($to->exists($t_fold)) {
print "To Folder $t_fold does not exist\n"; print "To Folder $t_fold does not exist\n";
print "Creating folder $t_fold\n"; print "Creating folder [$t_fold]\n";
unless ($dry){ unless ($dry){
unless ($to->create($t_fold)){ unless ($to->create($t_fold)){
warn "Couldn't create $t_fold ", warn "Couldn't create [$t_fold]",
$to->LastError,"\n"; $to->LastError,"\n";
$error++; $error++;
next FOLDER; next FOLDER;
@ -344,7 +347,7 @@ sub header_parse {
my $f_msg = $f_hash{$m_id}{'m'}; my $f_msg = $f_hash{$m_id}{'m'};
$debug and print "key $m_id #$f_msg\n"; $debug and print "key $m_id #$f_msg\n";
unless (exists($t_hash{$m_id})) { unless (exists($t_hash{$m_id})) {
print "Message NO msg #$f_msg $m_id in $t_fold\n"; print "Message NO msg #$f_msg [$m_id] in $t_fold\n";
# copy # copy
print "Copying msg #$f_msg:$f_size to folder $t_fold\n"; print "Copying msg #$f_msg:$f_size to folder $t_fold\n";
unless ($dry) { unless ($dry) {
@ -357,8 +360,11 @@ sub header_parse {
$error++; $error++;
next MESS; next MESS;
}else{ }else{
# good # good
print "Copied msg #$f_msg to folder $t_fold msg #$new_id\n"; # $new_id is an id if the IMAP server has the
# UIDPLUS capability else just a ref
print "Copied msg id [$f_msg] to folder $t_fold msg id [$new_id]\n";
$to->store($new_id, $to->store($new_id,
"+FLAGS (" . join(" ", "+FLAGS (" . join(" ",
@{$from->flags($f_msg)} @{$from->flags($f_msg)}
@ -367,7 +373,7 @@ sub header_parse {
} }
next MESS; next MESS;
}else{ }else{
$debug and print "Message $m_id found in t:$t_fold\n"; $debug and print "Message id [$m_id] found in t:$t_fold\n";
} }
#$debug and print "MESSAGE $m_id\n"; #$debug and print "MESSAGE $m_id\n";
my $t_size = $t_hash{$m_id}{'s'}; my $t_size = $t_hash{$m_id}{'s'};

View file

@ -1,8 +1,11 @@
#!/bin/sh #!/bin/sh
# $Id: tests.sh,v 1.3 2003/05/05 22:32:01 gilles Exp $ # $Id: tests.sh,v 1.4 2003/08/21 15:40:32 gilles Exp $
# $Log: tests.sh,v $ # $Log: tests.sh,v $
# Revision 1.4 2003/08/21 15:40:32 gilles
# Added a email in loulplume test
#
# Revision 1.3 2003/05/05 22:32:01 gilles # Revision 1.3 2003/05/05 22:32:01 gilles
# Added pl_folder() test # Added pl_folder() test
# #
@ -87,6 +90,12 @@ first_sync() {
loulplume() { loulplume() {
if test X`hostname` = X"plume"; then if test X`hostname` = X"plume"; then
echo3 Here is plume echo3 Here is plume
rand=`pwgen 16 1`
mess='test:'$rand
cmd="echo $mess""| mail -s ""$mess"" tata"
echo $cmd
ssh gilles@loul $cmd
sleep 10
./imapsync \ ./imapsync \
--host1 loul --user1 tata --passfile1 /var/tmp/secret.tata \ --host1 loul --user1 tata --passfile1 /var/tmp/secret.tata \
--host2 plume --user2 tata@est.belle --passfile2 /var/tmp/secret.tata --host2 plume --user2 tata@est.belle --passfile2 /var/tmp/secret.tata
@ -111,7 +120,7 @@ lp_folder() {
echo3 Here is plume echo3 Here is plume
./imapsync \ ./imapsync \
--host2 plume --user2 tata@est.belle --passfile2 /var/tmp/secret.tata \ --host2 plume --user2 tata@est.belle --passfile2 /var/tmp/secret.tata \
--folder INBOX.yop \ --folder INBOX.yop --folder INBOX.Trash \
--host1 loul --user1 tata --passfile1 /var/tmp/secret.tata --host1 loul --user1 tata --passfile1 /var/tmp/secret.tata
else else
: :