1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-17 00:02:29 +01:00
This commit is contained in:
Nick Bebout 2011-03-12 02:43:50 +00:00
parent 60f3bae1be
commit d5e50a6fb9
7 changed files with 219 additions and 37 deletions

View File

@ -1,15 +1,29 @@
RCS file: RCS/imapsync,v RCS file: RCS/imapsync,v
Working file: imapsync Working file: imapsync
head: 1.65 head: 1.68
branch: branch:
locks: strict locks: strict
access list: access list:
symbolic names: symbolic names:
keyword substitution: kv keyword substitution: kv
total revisions: 65; selected revisions: 65 total revisions: 68; selected revisions: 68
description: description:
---------------------------- ----------------------------
revision 1.68
date: 2004/01/28 03:49:29; author: gilles; state: Exp; lines: +17 -13
Added "Success stories"
Sorted "Success stories"
Added windows note.
----------------------------
revision 1.67
date: 2004/01/28 03:10:24; author: gilles; state: Exp; lines: +6 -6
Better description for google.
----------------------------
revision 1.66
date: 2004/01/23 20:27:28; author: gilles; state: Exp; lines: +6 -6
Added IMAP sync words for google response.
----------------------------
revision 1.65 revision 1.65
date: 2003/12/24 03:04:34; author: gilles; state: Exp; lines: +20 -7 date: 2003/12/24 03:04:34; author: gilles; state: Exp; lines: +20 -7
Wrote separator_invert() Wrote separator_invert()

20
INSTALL
View File

@ -1,7 +1,7 @@
# $Id: INSTALL,v 1.6 2003/11/21 03:13:52 gilles Exp gilles $ # $Id: INSTALL,v 1.7 2004/01/28 04:00:55 gilles Exp gilles $
# #
# INSTALL file for ftpsync # INSTALL file for imapsync
# imapsync : IMAP sync or copy tool.
GETTING GETTING
------- -------
@ -26,10 +26,20 @@ You need :
http://search.cpan.org/~djkernen/ http://search.cpan.org/~djkernen/
http://search.cpan.org/~djkernen/Mail-IMAPClient-2.2.9/ http://search.cpan.org/~djkernen/Mail-IMAPClient-2.2.9/
In fact I use Mail-IMAPClient-2.1.4 In fact I use Mail-IMAPClient-2.1.4 (debian package)
To know the version you have on your system try : To know the version you have on your system try :
perl -mMail::IMAPClient -e 'print $Mail::IMAPClient::VERSION, "\n"' perl -mMail::IMAPClient -e 'print $Mail::IMAPClient::VERSION, "\n"'
- Perl Digest::MD5 module.
http://search.cpan.org/
http://search.cpan.org/~gaas/Digest-MD5-2.33/
To know the version you have on your system try :
perl -mDigest::MD5 -e 'print $Digest::MD5::VERSION, "\n"'
I use 2.20 (debian package)
- (Option) Perl Digest::HMAC_MD5 module
Good for non plain text password over network.
INSTALLING INSTALLING
---------- ----------

30
README
View File

@ -1,9 +1,13 @@
NAME NAME
imapsync - synchronize mailboxes between two imap servers. imapsync - IMAP sync or copy tool. Synchronize mailboxes between two
imap servers.
$Revision: 1.65 $ $Revision: 1.68 $
INSTALL INSTALL
imapsync works fine under any Unix OS.
imapsync works fine under Windows 2000 (at least) and ActiveState's 5.8 Perl
Get imapsync at Get imapsync at
http://www.linux-france.org/prj/imapsync/dist/ http://www.linux-france.org/prj/imapsync/dist/
@ -128,18 +132,20 @@ BUGS
Report any bugs to the author: lamiral@linux-france.org Report any bugs to the author: lamiral@linux-france.org
IMAP SERVERS IMAP SERVERS
Success stories reported : Success stories reported (softwares in alphabetic order) :
- Courier IMAP 1.5.1, 2.2.0, 2.1.1
- Cyrus IMAP 1.5, 1.6, 2.1, 2.1.15, 2.2.1, Cyrus 2.2.2-BETA
- Netscape Mail Server 3.6 (Wintel)
- CommunicatePro server (Redhat 8.0)
- SunONE Messaging server 5.2
- iPlanet Messaging server 4.15
- dovecot ?.??
- UW-imap servers (imap-2000b) rijkkramer IMAP4rev1 2000.287
- BincImap 1.2.3 - BincImap 1.2.3
- CommunicatePro server (Redhat 8.0)
- Courier IMAP 1.5.1, 2.2.0, 2.1.1
- Critical Path (7.0.020)
- Cyrus IMAP 1.5, 1.6, 2.1, 2.1.15, 2.2.1, Cyrus 2.2.2-BETA
- DBMail 1.2.1 - DBMail 1.2.1
- dovecot ?.??
- iPlanet Messaging server 4.15
- Netscape Mail Server 3.6 (Wintel !)
- SunONE Messaging server 5.2, 6.0 (SUN JES - Java Enterprise System)
- UW-imap servers (imap-2000b) rijkkramer IMAP4rev1 2000.287
- UW - QMail v2.1
Please report to the author any success or bad story with imapsync and Please report to the author any success or bad story with imapsync and
don't forget to mention the IMAP server software names and version on don't forget to mention the IMAP server software names and version on
@ -184,5 +190,5 @@ SIMILAR SOFTWARES
Feedback (good or bad) will be always welcome. Feedback (good or bad) will be always welcome.
$Id: imapsync,v 1.65 2003/12/24 03:04:34 gilles Exp $ $Id: imapsync,v 1.68 2004/01/28 03:49:29 gilles Exp $

4
TODO
View File

@ -1,8 +1,10 @@
TODO file for imapsync TODO file for imapsync
---------------------- ----------------------
Look at http://freshmeat.net/projects/freshmeat-submit/
Look at comp.mail.imap
Add a --recurse option. Add a --recurse option when --folder option is used.
Add --prefix1 option. Don't know what is the need exactly. Add --prefix1 option. Don't know what is the need exactly.

View File

@ -1 +1 @@
1.65 1.68

View File

@ -2,12 +2,15 @@
=head1 NAME =head1 NAME
imapsync - synchronize mailboxes between two imap servers. imapsync - IMAP sync or copy tool. Synchronize mailboxes between two imap servers.
$Revision: 1.65 $ $Revision: 1.68 $
=head1 INSTALL =head1 INSTALL
imapsync works fine under any Unix OS.
imapsync works fine under Windows 2000 (at least) and ActiveState's 5.8 Perl
Get imapsync at Get imapsync at
http://www.linux-france.org/prj/imapsync/dist/ http://www.linux-france.org/prj/imapsync/dist/
@ -150,19 +153,20 @@ Report any bugs to the author: lamiral@linux-france.org
=head1 IMAP SERVERS =head1 IMAP SERVERS
Success stories reported : Success stories reported (softwares in alphabetic order) :
- Courier IMAP 1.5.1, 2.2.0, 2.1.1
- Cyrus IMAP 1.5, 1.6, 2.1, 2.1.15, 2.2.1, Cyrus 2.2.2-BETA
- Netscape Mail Server 3.6 (Wintel)
- CommunicatePro server (Redhat 8.0)
- SunONE Messaging server 5.2
- iPlanet Messaging server 4.15
- dovecot ?.??
- UW-imap servers (imap-2000b) rijkkramer IMAP4rev1 2000.287
- BincImap 1.2.3 - BincImap 1.2.3
- CommunicatePro server (Redhat 8.0)
- Courier IMAP 1.5.1, 2.2.0, 2.1.1
- Critical Path (7.0.020)
- Cyrus IMAP 1.5, 1.6, 2.1, 2.1.15, 2.2.1, Cyrus 2.2.2-BETA
- DBMail 1.2.1 - DBMail 1.2.1
- dovecot ?.??
- iPlanet Messaging server 4.15
- Netscape Mail Server 3.6 (Wintel !)
- SunONE Messaging server 5.2, 6.0 (SUN JES - Java Enterprise System)
- UW-imap servers (imap-2000b) rijkkramer IMAP4rev1 2000.287
- UW - QMail v2.1
Please report to the author any success or bad story with Please report to the author any success or bad story with
imapsync and don't forget to mention the IMAP server imapsync and don't forget to mention the IMAP server
@ -220,7 +224,7 @@ Welcome in shell programming !
Feedback (good or bad) will be always welcome. Feedback (good or bad) will be always welcome.
$Id: imapsync,v 1.65 2003/12/24 03:04:34 gilles Exp $ $Id: imapsync,v 1.68 2004/01/28 03:49:29 gilles Exp $
=cut =cut
@ -251,7 +255,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.65 2003/12/24 03:04:34 gilles Exp $ '; $rcs = ' $Id: imapsync,v 1.68 2004/01/28 03:49:29 gilles Exp $ ';
$rcs =~ m/,v (\d+\.\d+)/; $rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN"; $VERSION = ($1) ? $1 : "UNKNOWN";
@ -282,8 +286,8 @@ $error=0;
my $banner = join("", my $banner = join("",
'$RCSfile: imapsync,v $ ', '$RCSfile: imapsync,v $ ',
'$Revision: 1.65 $ ', '$Revision: 1.68 $ ',
'$Date: 2003/12/24 03:04:34 $ ', '$Date: 2004/01/28 03:49:29 $ ',
"\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",

146
patches/imapsync.diff Normal file
View File

@ -0,0 +1,146 @@
--- imapsync.orig Wed Dec 24 04:04:34 2003
+++ imapsync Wed Jan 21 10:32:24 2004
@@ -34,10 +34,13 @@
[--host2 server2] [--port2 <num>]
[--user2 <string>] [--passfile2 <string>]
[--folder <string> --folder <string> ...]
+ [--include <regex>] [--exclude <regex>]
[--prefix2 <string>]
[--sep1 <char>]
[--sep2 <char>]
- [--syncinternaldate]
+ [--syncinternaldates]
+ [--maxsize <int>]
+ [--maxage <int>]
[--delete] [--expunge]
[--subscribed] [--subscribe]
[--dry]
@@ -239,9 +242,10 @@
$rcs, $debug, $debugimap, $error,
$host1, $host2, $port1, $port2,
$user1, $user2, $password1, $password2, $passfile1, $passfile2,
- @folder, $prefix2,
+ @folder, $include, $exclude, $prefix2,
$sep1, $sep2,
$syncinternaldates,
+ $maxsize, $maxage,
$delete, $expunge, $dry,
$subscribed, $subscribe,
$version, $VERSION, $help,
@@ -369,10 +373,19 @@
@f_folders = @folder;
}elsif ($subscribed) {
# option --subscribed
- @f_folders = keys (%fs_folders);
+ @f_folders = sort keys (%fs_folders);
}else {
# no option, all folders
- @f_folders = $from->folders()
+ @f_folders = sort $from->folders();
+ # consider (optional) includes and excludes
+ if ($include) {
+ @f_folders = grep /$include/,@f_folders;
+ print "Only including folders matching pattern '$include'\n";
+ }
+ if ($exclude) {
+ @f_folders = grep !/$exclude/,@f_folders;
+ print "Excluding folders matching pattern '$exclude'\n";
+ }
}
my($f_sep,$t_sep);
@@ -415,13 +428,13 @@
# my $tohasuidplus = $to->has_capability("UIDPLUS");
-@t_folders = @{$to->folders()};
+@t_folders = sort @{$to->folders()};
print
"From folders : ", map("[$_] ",@f_folders),"\n",
"To folders : ", map("[$_] ",@t_folders),"\n";
print
- "From subscribed folders : ", map("[$_] ", keys(%fs_folders)), "\n";
+ "From subscribed folders : ", map("[$_] ", sort keys(%fs_folders)), "\n";
sub separator_invert {
my $o_sep="\000";
@@ -485,9 +498,9 @@
unless($dry) { $to->subscribe($t_fold) };
}
- my @f_msgs = $from->search("ALL");
+ my @f_msgs = $maxage ? $from->since(time - 86400 * $maxage) : $from->search("ALL");
$debug and print "LIST FROM : @f_msgs\n";
- my @t_msgs = $to->search("ALL");
+ my @t_msgs = $maxage ? $to->since(time - 86400 * $maxage) : $to->search("ALL");
$debug and print "LIST TO : @t_msgs\n";
my %f_hash = ();
@@ -508,6 +521,10 @@
MESS: foreach my $m_id (keys(%f_hash)) {
my $f_size = $f_hash{$m_id}{'s'};
my $f_msg = $f_hash{$m_id}{'m'};
+ if (defined $maxsize and $f_size > $maxsize) {
+ print "Skipping msg #$f_msg:$f_size in folder $f_fold (exceeds maxsize limit)\n";
+ next MESS;
+ }
$debug and print "key $m_id #$f_msg\n";
unless (exists($t_hash{$m_id})) {
print "NO msg #$f_msg [$m_id] in $t_fold\n";
@@ -526,7 +543,7 @@
my $new_id;
print "flags from : [$flags_f][$d]\n";
unless($new_id = $to->append_string($t_fold,$string, $flags_f, $d)){
- warn "Couldn't append msg #$f_msg to folder $t_fold",
+ warn "Couldn't append msg #$f_msg (Subject: ".$from->subject($f_msg).") to folder $t_fold: ",
$to->LastError, "\n";
$error++;
next MESS;
@@ -619,9 +636,13 @@
"sep1=s" => \$sep1,
"sep2=s" => \$sep2,
"folder=s" => \@folder,
+ "include=s" => \$include,
+ "exclude=s" => \$exclude,
"prefix2=s" => \$prefix2,
"delete!" => \$delete,
"syncinternaldates!" => \$syncinternaldates,
+ "maxsize=i" => \$maxsize,
+ "maxage=i" => \$maxage,
"dry!" => \$dry,
"expunge!" => \$expunge,
"subscribed!" => \$subscribed,
@@ -656,8 +677,8 @@
return unless(scalar(keys(%$head)));
foreach my $h (sort keys(%$head)){
foreach my $val ( @{$head->{$h}}) {
- # no accent in headers !
- $val =~ y/éèàù/XXXX/;
+ # no 8-bit data in headers !
+ $val =~ s/[\x80-\xff]/X/g;
$debug and print "${s}H $h:", $val, "\n";
$headstr .= "$h:". $val;
}
@@ -704,6 +725,12 @@
--folder <string> : sync only this folder.
--folder <string> : and this one.
--folder <string> : and this one, etc.
+--include <regex> : only sync folders matching this regular expression
+ (only effective if neither --folder nor --subscribed
+ is specified)
+--exclude <regex> : skip folders matching this regular expression
+ (only effective if neither --folder nor --subscribed
+ is specified)
--prefix2 <string> : add prefix to all destination folders
(usually INBOX. for cyrus imap servers)
--sep1 <char> : separator in case namespace is not supported.
@@ -718,6 +745,8 @@
expunge is made at the begining so newly
transfered messages won't be expunged.
--syncinternaldates : set the internal dates on host2 same as host1
+--maxsize <int> : skip messages larger than <int> bytes
+--maxage <int> : skip messages older than <int> days
--dry : do nothing, just print what would be done.
--subscribed : transfer only subscribed folders.
--subscribe : subscribe to the folders transfered on the