This commit is contained in:
Nick Bebout 2011-03-12 02:44:12 +00:00
parent 8bef5e252c
commit c7f1a38411
6 changed files with 65 additions and 132 deletions

View file

@ -1,5 +1,8 @@
#!/bin/cat #!/bin/cat
Jean-Michel besnard
Pb with woody, Mail::ImapClient and fetch_hash
Jamie Neil Jamie Neil
Suggested --regexmess option Suggested --regexmess option

View file

@ -1,15 +1,24 @@
RCS file: RCS/imapsync,v RCS file: RCS/imapsync,v
Working file: imapsync Working file: imapsync
head: 1.116 head: 1.118
branch: branch:
locks: strict locks: strict
access list: access list:
symbolic names: symbolic names:
keyword substitution: kv keyword substitution: kv
total revisions: 116; selected revisions: 116 total revisions: 118; selected revisions: 118
description: description:
---------------------------- ----------------------------
revision 1.118
date: 2005/01/17 14:45:25; author: gilles; state: Exp; lines: +10 -8
--regexmess option can be repeated
----------------------------
revision 1.117
date: 2005/01/16 13:51:49; author: gilles; state: Exp; lines: +17 -11
Changed get_separator()
Calling namespace capability if needed
----------------------------
revision 1.116 revision 1.116
date: 2005/01/16 01:50:23; author: gilles; state: Exp; lines: +50 -49 date: 2005/01/16 01:50:23; author: gilles; state: Exp; lines: +50 -49
Added --regexmess option Added --regexmess option

4
README
View file

@ -2,7 +2,7 @@ NAME
imapsync - IMAP synchronization, copy or migration tool. Synchronize imapsync - IMAP synchronization, copy or migration tool. Synchronize
mailboxes between two imap servers. Good at IMAP migration. mailboxes between two imap servers. Good at IMAP migration.
$Revision: 1.116 $ $Revision: 1.118 $
INSTALL INSTALL
imapsync works fine under any Unix OS. imapsync works fine under any Unix OS.
@ -239,5 +239,5 @@ AUTHOR
teaching free open and gratis softwares. Don't hesitate to pay him for teaching free open and gratis softwares. Don't hesitate to pay him for
that services. that services.
$Id: imapsync,v 1.116 2005/01/16 01:50:23 gilles Exp $ $Id: imapsync,v 1.118 2005/01/17 14:45:25 gilles Exp $

View file

@ -1 +1 @@
1.116 1.118

View file

@ -6,7 +6,7 @@ imapsync - IMAP synchronization, copy or migration
tool. Synchronize mailboxes between two imap servers. Good tool. Synchronize mailboxes between two imap servers. Good
at IMAP migration. at IMAP migration.
$Revision: 1.116 $ $Revision: 1.118 $
=head1 INSTALL =head1 INSTALL
@ -281,7 +281,7 @@ Gilles LAMIRAL earn his living writing, installing,
configuring and teaching free open and gratis configuring and teaching free open and gratis
softwares. Don't hesitate to pay him for that services. softwares. Don't hesitate to pay him for that services.
$Id: imapsync,v 1.116 2005/01/16 01:50:23 gilles Exp $ $Id: imapsync,v 1.118 2005/01/17 14:45:25 gilles Exp $
=cut =cut
@ -300,7 +300,7 @@ my(
$rcs, $debug, $debugimap, $error, $rcs, $debug, $debugimap, $error,
$host1, $host2, $port1, $port2, $host1, $host2, $port1, $port2,
$user1, $user2, $password1, $password2, $passfile1, $passfile2, $user1, $user2, $password1, $password2, $passfile1, $passfile2,
@folder, $include, $exclude, $prefix2, $regextrans2, $regexmess, @folder, $include, $exclude, $prefix2, $regextrans2, @regexmess,
$sep1, $sep2, $sep1, $sep2,
$syncinternaldates, $syncacls, $syncinternaldates, $syncacls,
$maxsize, $maxage, $maxsize, $maxage,
@ -324,7 +324,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.116 2005/01/16 01:50:23 gilles Exp $ '; $rcs = ' $Id: imapsync,v 1.118 2005/01/17 14:45:25 gilles Exp $ ';
$rcs =~ m/,v (\d+\.\d+)/; $rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN"; $VERSION = ($1) ? $1 : "UNKNOWN";
@ -361,8 +361,8 @@ $error=0;
my $banner = join("", my $banner = join("",
'$RCSfile: imapsync,v $ ', '$RCSfile: imapsync,v $ ',
'$Revision: 1.116 $ ', '$Revision: 1.118 $ ',
'$Date: 2005/01/16 01:50:23 $ ', '$Date: 2005/01/17 14:45:25 $ ',
"\n", "\n",
"Mail::IMAPClient version used here is ", "Mail::IMAPClient version used here is ",
$VERSION_IMAPClient, " auth md5 : $md5_supported", $VERSION_IMAPClient, " auth md5 : $md5_supported",
@ -515,6 +515,8 @@ if (scalar(@folder)) {
} }
} }
@t_folders = sort @{$to->folders()};
my($f_sep,$t_sep); my($f_sep,$t_sep);
# what are the private folders separators for each server ? # what are the private folders separators for each server ?
@ -526,12 +528,17 @@ $t_sep = get_separator($to, $sep2, "--sep2");
sub get_separator { sub get_separator {
my($imap, $sep_in, $sep_opt) = @_; my($imap, $sep_in, $sep_opt) = @_;
my($sep_out); my($sep_out);
$debug and print "Calling namespace capability\n";
if ($sep_in) { if ($sep_in) {
print "Using [$sep_in] given by $sep_opt\n";
$sep_out = $sep_in; $sep_out = $sep_in;
}elsif ($imap->has_capability("namespace")) { return($sep_out);
}
$debug and print "Calling namespace capability\n";
if ($imap->has_capability("namespace")) {
$sep_out = $imap->separator(); $sep_out = $imap->separator();
return($sep_out);
}else{ }else{
print print
"No NAMESPACE capability in imap server ", "No NAMESPACE capability in imap server ",
@ -539,7 +546,6 @@ sub get_separator {
"Give the separator caracter with the $sep_opt option\n"; "Give the separator caracter with the $sep_opt option\n";
exit(1); exit(1);
} }
return($sep_out);
} }
@ -606,7 +612,7 @@ exit if ($justconnect);
my $tohasuidplus = $to->has_capability("UIDPLUS"); my $tohasuidplus = $to->has_capability("UIDPLUS");
@t_folders = sort @{$to->folders()};
print print
"From folders : ", map("[$_] ",@f_folders),"\n", "From folders : ", map("[$_] ",@f_folders),"\n",
"To folders : ", map("[$_] ",@t_folders),"\n"; "To folders : ", map("[$_] ",@t_folders),"\n";
@ -735,7 +741,7 @@ FOLDER: foreach my $f_fold (@f_folders) {
use Data::Dumper; use Data::Dumper;
#print Data::Dumper->Dump([$f_heads]); #print Data::Dumper->Dump([$f_heads]);
#print Data::Dumper->Dump([$f_flags]); #print Data::Dumper->Dump([$f_flags]);
#exit; #exit;
foreach my $m (@f_msgs) { foreach my $m (@f_msgs) {
parse_header_msg1($m, $f_heads, $f_size, "F", \%f_hash); parse_header_msg1($m, $f_heads, $f_size, "F", \%f_hash);
@ -779,7 +785,7 @@ FOLDER: foreach my $f_fold (@f_folders) {
# 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";
my $string = $from->message_string($f_msg); my $string = $from->message_string($f_msg);
if ($regexmess) { while (my $regexmess = shift(@regexmess)) {
$debug and print "eval \$string =~ $regexmess\n"; $debug and print "eval \$string =~ $regexmess\n";
eval("\$string =~ $regexmess"); eval("\$string =~ $regexmess");
@ -926,13 +932,13 @@ sub get_options
"exclude=s" => \$exclude, "exclude=s" => \$exclude,
"prefix2=s" => \$prefix2, "prefix2=s" => \$prefix2,
"regextrans2=s" => \$regextrans2, "regextrans2=s" => \$regextrans2,
"regexmess=s" => \$regexmess, "regexmess=s" => \@regexmess,
"delete!" => \$delete, "delete!" => \$delete,
"syncinternaldates!" => \$syncinternaldates, "syncinternaldates!" => \$syncinternaldates,
"syncacls!" => \$syncacls, "syncacls!" => \$syncacls,
"maxsize=i" => \$maxsize, "maxsize=i" => \$maxsize,
"maxage=i" => \$maxage, "maxage=i" => \$maxage,
"foldersizes" => \$foldersizes, "foldersizes!" => \$foldersizes,
"dry!" => \$dry, "dry!" => \$dry,
"expunge!" => \$expunge, "expunge!" => \$expunge,
"subscribed!" => \$subscribed, "subscribed!" => \$subscribed,
@ -1076,6 +1082,8 @@ Several options are mandatory.
--regextrans2 <regex> : Apply the whole regex to each destination folders. --regextrans2 <regex> : Apply the whole regex to each destination folders.
--regexmess <regex> : Apply the whole regex to each message before transfer. --regexmess <regex> : Apply the whole regex to each message before transfer.
Exemple : 's/\\000/ /g' # to replace null by space. Exemple : 's/\\000/ /g' # to replace null by space.
--regexmess <regex> : and this one.
--regexmess <regex> : and this one, etc.
--sep1 <string> : separator in case namespace is not supported. --sep1 <string> : separator in case namespace is not supported.
--sep2 <string> : idem. --sep2 <string> : idem.
--delete : delete messages in source imap server after --delete : delete messages in source imap server after

139
tests.sh
View file

@ -1,116 +1,6 @@
#!/bin/sh #!/bin/sh
# $Id: tests.sh,v 1.33 2005/01/16 01:49:49 gilles Exp $ # $Id: tests.sh,v 1.35 2005/01/17 14:47:49 gilles Exp $
# $Log: tests.sh,v $
# Revision 1.33 2005/01/16 01:49:49 gilles
# Added regexmess() test
#
# Revision 1.32 2005/01/10 00:15:41 gilles
# Added --fast for big_transfert()
#
# Revision 1.31 2005/01/04 04:50:12 gilles
# essnet update
#
# Revision 1.30 2004/12/28 23:22:02 gilles
# Added lp_justfolders()
#
# Revision 1.29 2004/12/28 04:03:12 gilles
# Added lp_sep2()
#
# Revision 1.28 2004/12/28 03:15:28 gilles
# essnet tests
#
# Revision 1.27 2004/11/18 03:56:43 gilles
# Added essnet_justconnect()
#
# Revision 1.26 2004/11/04 22:41:54 gilles
# renamed big_transfert2 -> dprof
#
# Revision 1.25 2004/10/15 14:40:05 gilles
# Added big_transfert_sizes_only()
#
# Revision 1.24 2004/10/12 21:18:10 gilles
# Added big_transfert2()
#
# Revision 1.23 2004/09/07 00:38:36 gilles
# Added noauthmd5 to first_sync test
#
# Revision 1.22 2004/07/09 09:11:28 gilles
# comment about pl and lp
#
# Revision 1.21 2004/07/09 09:00:13 gilles
# Added foldersizes2() to check old Mail-IMAPClient lib
#
# Revision 1.20 2004/07/08 23:32:36 gilles
# Added foldersizes() test
#
# Revision 1.19 2004/06/15 03:42:16 gilles
# success on bigtransfer()
#
# Revision 1.18 2004/06/14 23:03:41 gilles
# Added big_transfert()
#
# Revision 1.17 2004/04/07 18:13:29 gilles
# Added lp_regextrans2()
#
# Revision 1.16 2004/03/21 23:24:42 gilles
# Added
# lp_skipsize()
# lp_skipheader()
#
# Revision 1.15 2004/03/11 05:32:08 gilles
# Added bad_login()
# Added bad_host()
# Added lp_noauthmd5()
#
# Revision 1.14 2004/02/07 03:34:35 gilles
# Added lp_include()
#
# Revision 1.13 2004/01/29 04:21:54 gilles
# Added lp_maxage
# Added lp_maxsize
#
# Revision 1.12 2003/12/23 18:16:09 gilles
# Added lp_justconnect()
# Added lp_md5auth()
#
# Revision 1.11 2003/12/12 17:48:02 gilles
# Added lp_subscribe() test
#
# Revision 1.10 2003/11/21 03:20:14 gilles
# Renamed lp_folder_qqq() pl_folder_qqq()
# Removed --prefix2 INBOX. in pl_folder_qqq()
# Added lp_subscribed() test.
#
# Revision 1.9 2003/10/20 22:53:29 gilles
# Added lp_internaldate()
#
# Revision 1.8 2003/10/20 21:49:47 gilles
# wrote sendtestmessage()
#
# Revision 1.7 2003/10/17 01:34:16 gilles
# Added lp_folder_qqq() test
#
# Revision 1.6 2003/08/24 01:56:49 gilles
# Indented long lines
#
# Revision 1.5 2003/08/24 01:05:35 gilles
# Removed some variables
#
# 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
# Added pl_folder() test
#
# Revision 1.2 2003/05/05 21:05:49 gilles
# Added lp_folder to test --folder option
#
# Revision 1.1 2003/03/12 23:14:45 gilles
# Initial revision
#
#### Shell pragmas #### Shell pragmas
@ -186,12 +76,31 @@ loulplume() {
--host1 loul --user1 tata \ --host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \ --passfile1 /var/tmp/secret.tata \
--host2 plume --user2 tata@est.belle \ --host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata --passfile2 /var/tmp/secret.tata \
--nosyncacls
else else
: :
fi fi
} }
loulloul() {
if test X`hostname` = X"plume"; then
echo3 Here is plume
sendtestmessage
#sleep 10
./imapsync \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--host2 loul --user2 titi \
--passfile2 /var/tmp/secret.tata \
--sep2 .
else
:
fi
}
plumeloul() { plumeloul() {
if test X`hostname` = X"plume"; then if test X`hostname` = X"plume"; then
echo3 Here is plume echo3 Here is plume
@ -658,7 +567,11 @@ regexmess()
--host1 loul --user1 tata \ --host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \ --passfile1 /var/tmp/secret.tata \
--folder INBOX.yop.yap \ --folder INBOX.yop.yap \
--regexmess 's/\157/O/g' --dry --debug --regexmess 's/\157/O/g' \
--regexmess 's/p/Z/g' \
--dry --debug
echo 'rm /home/vmail/tata/.yop.yap/cur/*'
else else
: :
fi fi