equal
deleted
inserted
replaced
33 Usage: $ME <options> mailboxlist.txt |
33 Usage: $ME <options> mailboxlist.txt |
34 |
34 |
35 --dry-run dry run ($opt_dry) |
35 --dry-run dry run ($opt_dry) |
36 --skip skipp missing mailboxes ($opt_skip) |
36 --skip skipp missing mailboxes ($opt_skip) |
37 --logdir=s directory where logfiles will go to ($opt_logdir) |
37 --logdir=s directory where logfiles will go to ($opt_logdir) |
|
38 --maxage=i synchronize only mails younger than $(opt_maxage) |
38 --help this help text |
39 --help this help text |
39 # |
40 # |
40 |
41 |
41 use strict; |
42 use strict; |
42 use warnings; |
43 use warnings; |
58 my $imap_to_host = "pop.net.schlittermann.de"; |
59 my $imap_to_host = "pop.net.schlittermann.de"; |
59 |
60 |
60 my $opt_dry = 0; |
61 my $opt_dry = 0; |
61 my $opt_skip = 0; |
62 my $opt_skip = 0; |
62 my $opt_logdir = "./imapsync-log/"; |
63 my $opt_logdir = "./imapsync-log/"; |
|
64 my $opt_maxage = 0; |
63 |
65 |
64 GetOptions( |
66 GetOptions( |
65 "dry-ryn" => \$opt_dry, |
67 "dry-ryn" => \$opt_dry, |
66 "skip" => \$opt_skip, |
68 "skip" => \$opt_skip, |
67 "logdir=s" => \$opt_logdir, |
69 "logdir=s" => \$opt_logdir, |
|
70 "maxage=i" => \$opt_maxage, |
68 ) or die eval "\"$usage\""; |
71 ) or die eval "\"$usage\""; |
69 |
72 |
70 |
73 |
71 ### connection to mysql account database |
74 ### connection to mysql account database |
72 my $dbh = DBI->connect($dsn, $db_user, $db_pass, { RaiseError => 1} ) or |
75 my $dbh = DBI->connect($dsn, $db_user, $db_pass, { RaiseError => 1} ) or |
99 ### starting imap migration |
102 ### starting imap migration |
100 |
103 |
101 foreach my $mailbox (keys %password_of_account_) { |
104 foreach my $mailbox (keys %password_of_account_) { |
102 ### processing mailbox: $mailbox |
105 ### processing mailbox: $mailbox |
103 my $imapsync_options = ""; |
106 my $imapsync_options = ""; |
104 $imapsync_options .= " --dry" if $opt_dry; |
107 $imapsync_options .= " --dry" if $opt_dry; |
|
108 $imapsync_options .= " --maxage=$opt_maxage" if $opt_maxage > 0; |
|
109 |
105 my $logfile = "$opt_logdir/$mailbox.log"; |
110 my $logfile = "$opt_logdir/$mailbox.log"; |
106 |
111 |
107 my $cmd = sprintf( "imapsync %s --ssl1 --ssl2 --subscribe" |
112 my $cmd = sprintf( "imapsync %s --ssl1 --ssl2 --subscribe" |
108 . " --host1 %s --host2 %s" |
113 . " --host1 %s --host2 %s" |
109 . " --user1 %s --user2 %s --password1 %s --password2 %s > %s", |
114 . " --user1 %s --user2 %s --password1 %s --password2 %s > %s", |