Selasa, 20 Desember 2011

Sinkronisasi Mailbox Antar Mail Server dengan Imapsync





Hari ini saya sedang belajar untuk bagaimana caranya memindahkan mailbox email dari mail server-1 ke mail server-2. Memindahkan disini dalam artian memindahkan seluruh strukture dan isi mailbox fordernya.

Saya mendapatkan petunjuk dari artikel milik Mas Vavai yang kemudian saya coba dan berhasil, lalu saya tulis ulang dalam artikel ini dengan bahasa saya sendiri.

Imapsync ini merupakan tools yang cukup handal menurut saya karena mendukung multi platform dari beberapa jenis imap mail server yang berbeda, berikut daftar mail server yang sudah pernah dicoba :

- BincImap 1.2.3 (GPL) (http://www.bincimap.org/)
- CommuniGatePro server (Redhat 8.0)
- Courier IMAP 1.5.1, 2.2.0, 2.1.1, 2.2.1 (GPL)
(http://www.courier-mta.org/)
- Critical Path (7.0.020)
- Cyrus IMAP 1.5, 1.6, 2.1, 2.1.15, 2.1.16, 2.1.18
2.2.1, 2.2.2-BETA, 2.2.10, 2.2.12,
v2.2.3-Invoca-RPM-2.2.3-8,
2.3-alpha (OSI Approved),
v2.2.12-Invoca-RPM-2.2.12-3.RHEL4.1,
v2.3.1-Invoca-RPM-2.3.1-2.7.fc5,
(http://asg.web.cmu.edu/cyrus/)
- David Tobit V8 (proprietary Message system).
- DBMail 1.2.1, 2.0.4, 2.0.9, 2.2rc1 (GPL) (http://www.dbmail.org/).
2.0.7 seems buggy.
- Dovecot 0.99.10.4, 0.99.14, 0.99.14-8.fc4, 1.0-0.beta2.7 (LGPL)
(http://www.dovecot.org/)
- Domino (Notes) 6.5, 5.0.6, 5.0.7, 7.0.2, 6.0.2CF1
- Eudora WorldMail v2
- Groupwise IMAP (Novell) 6.x and 7.0. Buggy so see the FAQ.
- iPlanet Messaging server 4.15, 5.1, 5.2
- IMail 7.15 (Ipswitch/Win2003), 8.12
- MDaemon 7.0.1, 8.1, 9.5.4 (Windows server 2003 R2 platform)
- Mercury 4.1 (Windows server 2000 platform)
- Microsoft Exchange Server 5.5
- Netscape Mail Server 3.6 (Wintel !)
- Netscape Messaging Server 4.15 Patch 7
- OpenMail IMAP server B.07.00.k0 (Samsung Contact ?)
- OpenWave
- Qualcomm Worldmail (NT)
- Rockliffe Mailsite 5.3.11
- Samsung Contact IMAP server 8.5.0
- Scalix v10.1, 10.0.1.3, 11.0.0.431
- SmarterMail
- SunONE Messaging server 5.2, 6.0 (SUN JES - Java Enterprise System)
- Sun Java System Messaging Server 6.2-2.05
- Surgemail 3.6f5-5
- UW-imap servers (imap-2000b) rijkkramer IMAP4rev1 2000.287
(RedHat uses UW like 2003.338rh), v12.264 Solaris 5.7 (OSI Approved)
(http://www.washington.edu/imap/)
- UW - QMail v2.1
- Imap part of TCP/IP suite of VMS 7.3.2
- Zimbra-IMAP 3.0.1 GA 160, 3.1.0 Build 279, 4.0.5, 4.5.2, 5.5.

Untuk penjelasan detailnya silahkan lihat disini :http://manpages.ubuntu.com/manpages/gutsy/man1/imapsync.1.html


Berikut penjelasannya :

- Untuk mail server-1 saya menggunakan linux redhat dengan IP 10.10.10.1 dengan mail server xxx (bukan zimbra).
- Untuk mail server-2 saya menggunakan linux ubuntu server dengan IP 10.10.10.2 dengan zimbra mail server 7.

Disini saya akan melakukan sinkronisasi mailbox beserta struktur forldernya dari account dony@domainku.com pada mail server xxx ke account test@zimbra.domainku.com yang ada di mail server zimbra.

Lalu kemudian install imapsync pada ubuntu server :

mail-server-2# apt-get install imapsync


Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libdate-manip-perl libdigest-hmac-perl libdigest-sha1-perl libio-socket-ssl-perl libmail-imapclient-perl libnet-libidn-perl
libnet-ssleay-perl libparse-recdescent-perl libyaml-syck-perl
Suggested packages:
libio-socket-inet6-perl libauthen-sasl-perl
The following NEW packages will be installed:
imapsync libdate-manip-perl libdigest-hmac-perl libdigest-sha1-perl libio-socket-ssl-perl libmail-imapclient-perl libnet-libidn-perl
libnet-ssleay-perl libparse-recdescent-perl libyaml-syck-perl
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,311kB of archives.
After this operation, 18.2MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid/main libdigest-sha1-perl 2.12-1build1 [26.7kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ lucid/main libdigest-hmac-perl 1.01-7 [10.6kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libnet-ssleay-perl 1.35-2ubuntu1 [209kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libio-socket-ssl-perl 1.31-1 [58.3kB]
Get:5 http://us.archive.ubuntu.com/ubuntu/ lucid/main libyaml-syck-perl 1.07-1build1 [82.1kB]
Get:6 http://us.archive.ubuntu.com/ubuntu/ lucid/main libdate-manip-perl 6.05-1 [2,433kB]
Get:7 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libparse-recdescent-perl 1.963+dfsg-1 [153kB]
Get:8 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libmail-imapclient-perl 3.21-1 [234kB]
Get:9 http://us.archive.ubuntu.com/ubuntu/ lucid/universe imapsync 1.286+dfsg-3ubuntu1 [81.1kB]
Get:10 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libnet-libidn-perl 0.12.ds-1 [23.9kB]
Fetched 3,311kB in 18s (183kB/s)
Selecting previously deselected package libdigest-sha1-perl.
(Reading database ... 115186 files and directories currently installed.)
Unpacking libdigest-sha1-perl (from .../libdigest-sha1-perl_2.12-1build1_amd64.deb) ...
Selecting previously deselected package libdigest-hmac-perl.
Unpacking libdigest-hmac-perl (from .../libdigest-hmac-perl_1.01-7_all.deb) ...
Selecting previously deselected package libnet-ssleay-perl.
Unpacking libnet-ssleay-perl (from .../libnet-ssleay-perl_1.35-2ubuntu1_amd64.deb) ...
Selecting previously deselected package libio-socket-ssl-perl.
Unpacking libio-socket-ssl-perl (from .../libio-socket-ssl-perl_1.31-1_all.deb) ...
Selecting previously deselected package libyaml-syck-perl.
Unpacking libyaml-syck-perl (from .../libyaml-syck-perl_1.07-1build1_amd64.deb) ...
Selecting previously deselected package libdate-manip-perl.
Unpacking libdate-manip-perl (from .../libdate-manip-perl_6.05-1_all.deb) ...
Selecting previously deselected package libparse-recdescent-perl.
Unpacking libparse-recdescent-perl (from .../libparse-recdescent-perl_1.963+dfsg-1_all.deb) ...
Selecting previously deselected package libmail-imapclient-perl.
Unpacking libmail-imapclient-perl (from .../libmail-imapclient-perl_3.21-1_all.deb) ...
Selecting previously deselected package imapsync.
Unpacking imapsync (from .../imapsync_1.286+dfsg-3ubuntu1_all.deb) ...
Selecting previously deselected package libnet-libidn-perl.
Unpacking libnet-libidn-perl (from .../libnet-libidn-perl_0.12.ds-1_amd64.deb) ...
Processing triggers for man-db ...
Setting up libdigest-sha1-perl (2.12-1build1) ...
Setting up libdigest-hmac-perl (1.01-7) ...
Setting up libnet-ssleay-perl (1.35-2ubuntu1) ...
Setting up libio-socket-ssl-perl (1.31-1) ...
Setting up libyaml-syck-perl (1.07-1build1) ...
Setting up libdate-manip-perl (6.05-1) ...
Setting up libparse-recdescent-perl (1.963+dfsg-1) ...
Setting up libmail-imapclient-perl (3.21-1) ...
Setting up imapsync (1.286+dfsg-3ubuntu1) ...
Setting up libnet-libidn-perl (0.12.ds-1) ...
mail-server-2#

Sebelum melanjutkan pastikan dari mail-server-1 bisa telnet ke port imap milik mail-server-2. Setelah selesai diinstall imapsync nya maka kita dapat menjalankan commandnya sebagai berikut :


mail-server-2# imapsync --host1 10.10.10.1 --user1 dony@domainku.com --password1 123456 --host2 10.10.10.2 --user2 test@zimbra.domainku.com --password2 123456 --noauthmd5 -ssl2


$RCSfile: imapsync,v $ $Revision: 1.286 $ $Date: 2009/07/24 15:53:04 $
Here is a [linux] system (Linux mail 2.6.32-33-server #72-Ubuntu SMP Fri Jul 29 21:21:55 UTC 2011 x86_64)
with perl 5.10.1
Mail::IMAPClient 3.21
IO::Socket 1.31
IO::Socket::SSL
Digest::MD5 2.39
Digest::HMAC_MD5
Term::ReadKey 2.30
Date::Manip
and the module Mail::IMAPClient version used here is 3.21
Command line used:
/usr/bin/imapsync --host1 10.10.10.1 --user1 dony.ramansyah@domainku.com --password1 MASKED --host2 10.10.10.2 --user2 test@zimbra.domainku.com --password2 MASKED --noauthmd5
Turned ON syncinternaldates, will set the internal dates (arrival dates) on host2 same as host1.
TimeZone:[asia/jakarta]
Will try to use LOGIN authentication on host1
Will try to use LOGIN authentication on host2
From imap server [10.10.10.1] port [143] user [dony.ramansyah@domainku.com]
To imap server [10.10.10.2] port [143] user [test@zimbra.domainku.com]
Banner: * OK IMAP4 server ready (7.2.033.1)
Host 10.10.10.1 says it has NO CAPABILITY for AUTHENTICATE LOGIN
Success login on [10.10.10.1] with user [dony.ramansyah@domainku.com] auth [LOGIN]
Banner: * OK IMAP4 ready
Host 10.10.10.2 says it has NO CAPABILITY for AUTHENTICATE LOGIN
Error login: [10.10.10.2] with user [test@zimbra.domainku.com] auth [LOGIN]: 2 BAD invalid command
Error login: [10.10.10.2] with user [test@zimbra.domainku.com] auth [LOGIN]: 2 BAD invalid command
mail-server-2# imapsync --host1 10.10.10.1 --user1 dony.ramansyah@domainku.com --password1 wiro212 --host2 10.10.10.2 --user2 test@zimbra.domainku.com --password2 123456 --noauthmd5 -ssl2
$RCSfile: imapsync,v $ $Revision: 1.286 $ $Date: 2009/07/24 15:53:04 $
Here is a [linux] system (Linux mail 2.6.32-33-server #72-Ubuntu SMP Fri Jul 29 21:21:55 UTC 2011 x86_64)
with perl 5.10.1
Mail::IMAPClient 3.21
IO::Socket 1.31
IO::Socket::SSL
Digest::MD5 2.39
Digest::HMAC_MD5
Term::ReadKey 2.30
Date::Manip
and the module Mail::IMAPClient version used here is 3.21
Command line used:
/usr/bin/imapsync --host1 10.10.10.1 --user1 dony.ramansyah@domainku.com --password1 MASKED --host2 10.10.10.2 --user2 test@zimbra.domainku.com --password2 MASKED --noauthmd5 -ssl2
Turned ON syncinternaldates, will set the internal dates (arrival dates) on host2 same as host1.
TimeZone:[asia/jakarta]
Will try to use LOGIN authentication on host1
Will try to use LOGIN authentication on host2
From imap server [10.10.10.1] port [143] user [dony.ramansyah@domainku.com]
To imap server [10.10.10.2] port [993] user [test@zimbra.domainku.com]
Banner: * OK IMAP4 server ready (7.2.033.1)
Host 10.10.10.1 says it has NO CAPABILITY for AUTHENTICATE LOGIN
Success login on [10.10.10.1] with user [dony.ramansyah@domainku.com] auth [LOGIN]
Banner: * OK IMAP4 ready
Host 10.10.10.2 says it has NO CAPABILITY for AUTHENTICATE LOGIN
Success login on [10.10.10.2] with user [test@zimbra.domainku.com] auth [LOGIN]
host1: state Authenticated
host2: state Authenticated
From separator and prefix: [/][]
To separator and prefix: [/][]
++++ Calculating sizes ++++
From Folder [INBOX] Size: 4077212 Messages: 89
From Folder [Trash] Size: 0 Messages: 0
Total size: 4077212
Total messages: 89
Time: 0 s
++++ Calculating sizes ++++
To Folder [INBOX] Size: 11929 Messages: 4
To Folder [Trash] Size: 0 Messages: 0
Total size: 11929
Total messages: 4
Time: 1 s
++++ Listing folders ++++
From folders list: [INBOX] [Trash]
To folders list: [Chats] [Contacts] [Drafts] [Emailed Contacts] [INBOX] [Junk] [Sent] [Trash]
++++ Looping on each folder ++++
From Folder [INBOX]
To Folder [INBOX]
++++ From [INBOX] Parse 1 ++++
++++ To [INBOX] Parse 1 ++++
++++ Verifying [INBOX] -> [INBOX] ++++
+ NO msg #15312 [5wwCA0MS/yQVXhPhmpB9XQ:5263] in INBOX
+ Copying msg #15312:5263 to folder INBOX
flags from: [\Seen]["05-Sep-2011 11:03:42 +0700"]
Copied msg id [15312] to folder INBOX msg id [280]
+ NO msg #15313 [aAAxkl3uZONLMXgFbvKgoQ:7162] in INBOX
+ Copying msg #15313:7162 to folder INBOX
flags from: [\Seen]["05-Sep-2011 11:23:09 +0700"]
Copied msg id [15313] to folder INBOX msg id [281]
+ NO msg #15314 [YaalYRXz5HKImLsHREkz4Q:861010] in INBOX
+ Copying msg #15314:861010 to folder INBOX
flags from: [\Seen]["05-Sep-2011 11:26:05 +0700"]
Copied msg id [15314] to folder INBOX msg id [282]
+ NO msg #15315 [2/LRh0Uei7hItq39CCxkkA:6126] in INBOX

Time: 5 s
From Folder [Trash]
To Folder [Trash]
++++ From [Trash] Parse 1 ++++
++++ To [Trash] Parse 1 ++++
++++ Verifying [Trash] -> [Trash] ++++
Time: 0 s
++++ End looping on each folder ++++
++++ Statistics ++++
Time : 6 sec
Messages transferred : 89
Messages skipped : 0
Total bytes transferred: 4077212
Total bytes skipped : 0
Total bytes error : 0
Detected 0 errors

Happy with this free, open and gratis GPL software?
Please, thank the author (Gilles LAMIRAL) by giving him a book:
http://www.amazon.com/gp/registry/wishlist/1C9UNDIH3P7R7/
or rate imapsync at http://freshmeat.net/projects/imapsync/
mail-server-2#

Jika muncul tampilan output seperti diatas maka proses sinkronisasi berhasil dengan baik. Silahkan di cek pada account tujuan (test@zimbra.domainku.com) apakah isi emailnya sudah sama dengan account yang existing (dony@domainku.com).

Berikut penjelasan dari command perintahnya :

# imapsync --host1 10.10.10.1 --user1 dony@domainku.com --password1 123456 --host2 10.10.10.2 --user2 test@zimbra.domainku.com --password2 123456 --noauthmd5 -ssl2

- host1 dengan IP 10.10.10.1 adalah mail-server-1 dengan account dony@domainku.com dan passwordnya 123456
- host2 dengan IP 10.10.10.2 adalah mail-server-1 dengan account test@zimbra.domainku.com dan passwordnya 123456
- "-ssl2" karena imap dari mail-server-2 (zimbra) mengharuskan lewat koneksi ssl, sedangkan mail-server-1 tidak pakai ssl.
- 143 adalah port dari protocol tcp imap tanpa ssl, sedangkan port 993 adalah port tcp dari protocol imap dengan ssl.

Jadi yang saya lakukan adalah melakukan sinkronisasi mailbox beserta strukture forldernya dari account dony@domainku.com pada mail server xxx ke account test@zimbra.domainku.com yang ada di mail server zimbra.


Semoga bermanfaat untuk catatan pribadi saya dan teman semua..


Dony Ramansyah
site : http://dony-ramansyah.bravehost.com
blog : dony-ramansyah.blogspot.com
email : dony.ramansyah[at]gmail.com
Registered linux user : ID 400171

Tidak ada komentar:

Posting Komentar

jika agan dan aganwati mau titip komentar atau pesan dipersilahkan ya