Czasami zdarza się taki moment, że nas serwer jest za stary, by go migrować i trzeba jakoś przenieść serwer, czasami admini chcą zmienić serwer pocztowy na jakieś inne rozwiązanie typu przenieść się na serwer Exchange z Postfix/Dovecot, lub po prostu zmienić dostawcę pocztowego, bo ileż można dostawać spam od Onetu czy WP? Poza takimi błahostkami jak przeniesienie prywatnej skrzynki pocztowej te narzędzie pozwala na masowe przenoszenie skrzynek. Jedyny minus rozwiązania jest taki, że trzeba zresetować wszystkim hasła na czas migracji.
Postaram się pokazać kilka scenariuszy przenoszenia skrzynek, przy czym w dużej mierze początkowa instalacja zawsze jest taka sama – jedyna różnica jest w ustawieniach programu. IMAPsync jest aplikacją, która zadziała na Windowsie i Linuksie, ale szczerze powiedziawszy miałem problem z jej działaniem spod Windowsa, więc używam Linuksa do operacji na nim. W przypadku posiadania Windowsa używam Linux Subsystem for Windows (WSL), bo dzięki temu na tym samym hoście można korzystać na wybranej dystrybucji Linuksa bez jakichkolwiek problemów.
Pierwszą rzeczą, którą należy zrobić jest włączenie funkcji w Windows 10/Windows Server 2016/Windows Server 2019:
Następnie, w przypadku Windows 10 znajdujemy w Microsoft Store aplikację o nazwie Ubuntu 18.04
(miałem problemy z działaniem IMAPsync na 20.04, prawdopodobnie ze względu na inną wersję OpenSSL) i ją instalujemy:
W Windowsie Server jest o tyle inaczej, że nie ma tam Microsoft Store. Taką paczkę należy pobrać z Internetu i zmienić jej format na .zip, bo w rzeczywistości to jest archiwum. Całość jest opisana w tym dokumencie. Na wypadek, gdyby zniknął, ściągamy z tego linku plik.
Zanim odpalimy aplikację, musimy uruchomić system ponownie. Jeśli tego nie zrobimy, najpewniej zobaczymy ten błąd:
W przypadku Windows Server należy odpalić aplikację ubuntu1804.exe
, która jest wewnątrz rozpakowanego archiwum.
Po restarcie należy zdefiniować konto użytkownika i hasło:
Po tym należy wykonać polecenia, aby zainstalować IMAPsynca:
01 02 03 04 05 06 07 08 09 10 | sudo apt update sudo apt install libauthen-ntlm-perl libclass-load-perl libcrypt-ssleay-perl libdata-uniqid-perl libdigest-hmac-perl libdist-checkconflicts-perl \ libencode-imaputf7-perl libfile-copy-recursive-perl libfile-tail-perl libio-compress-perl libio-socket-inet6-perl libio-socket-ssl-perl libio-tee-perl \ libmail-imapclient-perl libmodule-scandeps-perl libnet-dbus-perl libnet-ssleay-perl libpar-packer-perl libreadonly-perl libregexp-common-perl \ libsys-meminfo-perl libterm-readkey-perl libtest-fatal-perl libtest-mock-guard-perl libtest-mockobject-perl libtest-pod-perl libtest-requires-perl \ libtest-simple-perl libunicode-string-perl liburi-perl libtest-nowarnings-perl libtest-deep-perl libtest-warn-perl make cpanminus apt-file libcrypt-openssl-rsa-perl libjson-webtoken-perl libcrypt-openssl-bignum-perl libcgi-pm-perl sudo cpanm CGI git clone https://github.com/imapsync/imapsync cd imapsync/INSTALL.d sudo ./prerequisites_imapsync |
Jeśli wynik jest następujący – powinniśmy dostać mniej więcej następujący wynik:
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | supra@supra-pc:~/imapsync/INSTALL.d$ sudo ./prerequisites_imapsync $SHELL says /bin/bash $0 gives ./prerequisites_imapsync ps -ef gives root 15542 15541 0 10:42 tty1 00:00:00 /bin/sh ./prerequisites_imapsync Distributor ID: Ubuntu Description: Ubuntu 18.04.4 LTS Release: 18.04 Codename: bionic Linux supra-pc 4.4.0-19041-Microsoft #1-Microsoft Fri Dec 06 14:06:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux Ok: Found Perl 5.26.1 make: Nothing to be done for 'foo'. Ok: Found make GNU Make 4.1 Ok: Found Perl module App::cpanminus Ok: Found Perl module Authen::NTLM Ok: Found Perl module CGI Ok: Found Perl module Compress::Zlib Ok: Found Perl module Crypt::OpenSSL::RSA Ok: Found Perl module Data::Dumper Ok: Found Perl module Data::Uniqid Ok: Found Perl module Digest::HMAC Ok: Found Perl module Digest::HMAC_MD5 Ok: Found Perl module Digest::MD5 Ok: Found Perl module Dist::CheckConflicts Ok: Found Perl module Encode Ok: Found Perl module Encode::Byte Ok: Found Perl module Encode::IMAPUTF7 Ok: Found Perl module File::Copy::Recursive Ok: Found Perl module File::Tail Ok: Found Perl module IO::Socket::INET Ok: Found Perl module IO::Socket::INET6 Ok: Found Perl module IO::Socket::SSL Ok: Found Perl module IO::Tee Ok: Found Perl module JSON Ok: Found Perl module JSON::WebToken Ok: Found Perl module JSON::WebToken::Crypt::RSA Ok: Found Perl module HTML::Entities Ok: Found Perl module LWP::UserAgent Ok: Found Perl module Mail::IMAPClient Ok: Found Perl module MIME::Base64 Ok: Found Perl module Module::Implementation Ok: Found Perl module Module::Runtime Ok: Found Perl module Module::ScanDeps Ok: Found Perl module Net::SSLeay Ok: Found Perl module Package::Stash Ok: Found Perl module Package::Stash::XS Ok: Found Perl module PAR::Packer Ok: Found Perl module Parse::RecDescent Ok: Found Perl module Pod::Usage Ok: Found Perl module Readonly Ok: Found Perl module Regexp::Common Ok: Found Perl module Sys::MemInfo Ok: Found Perl module Term::ReadKey Ok: Found Perl module Test::Fatal Ok: Found Perl module Test::Mock::Guard Ok: Found Perl module Test::MockObject Ok: Found Perl module Test::More Ok: Found Perl module Test::Pod Ok: Found Perl module Test::Requires Ok: Found Perl module Test::Deep Ok: Found Perl module Text::ParseWords Ok: Found Perl module Try::Tiny Ok: Found Perl module Unicode::String Ok: Found Perl module URI::Escape All needed modules are already installed Ok: Found cpanm cpanm (App::cpanminus) version 1.7043 (/usr/bin/cpanm) |
Mając to można wrócić do głównego katalogu sklonowanego repozytorium Gita i zanim odpalimy IMAPsync warto sprawdzić dane do serwera pocztowego. Aby wykonać synchronizację, należy podać dane skrzynki, z której synchronizujemy wiadomości:
- adres serwera pocztowego (opcja
--host1
), - port serwera pocztowego (opcja
--port1
, często opcjonalne, bo IMAPsync w przypadku prawidłowo zdefiniowanych wpisów w DNS sam wykryje odpowiedni port), - nazwa konta użytkownika (opcja
--user1
), - hasło konta użytkownika (opcja
--password1
), - wymuszenie wykorzystywania SSL (opcja
--ssl1
).
To samo podajemy dla docelowego serwera i użytkownika, lecz wykorzystujemy parametry z numerkiem 2 na końcu (np. --host2
).
Wcześniej warto sprawdzić na jakim porcie serwer pocztowy nasłuchuje. Poniżej wykonuję test dla serwera OVH, to znaczy ssl0.ovh.net
:
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | supra@supra-pc:/mnt/r/supra/Pobrane/imapsync-imapsync-1.945$ openssl s_client -connect ssl0.ovh.net:993 --showcerts -servername ssl0.ovh.net CONNECTED(00000003) depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority verify return:1 depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA verify return:1 depth=0 CN = ssl0.ovh.net verify return:1 --- Certificate chain 0 s:CN = ssl0.ovh.net i:C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA -----BEGIN CERTIFICATE----- MIIGujCCBaKgAwIBAgIRAKNd5nTWqiwzvsziDTAPdk4wDQYJKoZIhvcNAQELBQAw gY8xCzAJBgNVBAYTAkdCMRswG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6p/272dFMzav ToVNMOK0AVYARP8W0mYeWfzIor+sjIwRshNrUbi112PKxhcozm9KW8tbagmw8w== -----END CERTIFICATE----- 1 s:C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA i:C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority -----BEGIN CERTIFICATE----- MIIGEzCCA/ugAwIBAgIQfVtRJrR2uhHbdBYLvFMNpzANBgkqhkiG9w0BAQwFADCB iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTgx MTAyMDAwMDAwWhcNMzAxMjMxMjM1OTU5WjCBjzELMAkGA1UEBhMCR0IxGzAZBgNV BAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEYMBYGA1UE ChMPU2VjdGlnbyBMaW1pdGVkMTcwNQYDVQQDEy5TZWN0aWdvIFJTQSBEb21haW4g VmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC AQ8AMIIBCgKCAQEA1nMz1tc8INAA0hdFuNY+B6I/x0HuMjDJsGz99J/LEpgPLT+N TQEMgg8Xf2Iu6bhIefsWg06t1zIlk7cHv7lQP6lMw0Aq6Tn/2YHKHxYyQdqAJrkj eocgHuP/IJo8lURvh3UGkEC0MpMWCRAIIz7S3YcPb11RFGoKacVPAXJpz9OTTG0E oKMbgn6xmrntxZ7FN3ifmgg0+1YuWMQJDgZkW7w33PGfKGioVrCSo1yfu4iYCBsk Haswha6vsC6eep3BwEIc4gLw6uBK0u+QDrTBQBbwb4VCSmT3pDCg/r8uoydajotY uK3DGReE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b2qHSihrZe68Zk6s+go/lunrotEbaGmAhY LcmsJWTyXnW0OMGuf1pGg+pRyrbxmRE1a6Vqe8YAsOf4vmSyrcjC8azjUeqkk+B5 yOGBQMkKW+ESPMFgKuOXwIlCypTPRpgSabuY0MLTDXJLR27lk8QyKGOHQ+SwMj4K 00u/I5sUKUErmgQfky3xxzlIPK1aEn8= -----END CERTIFICATE----- 2 s:C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority i:C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority -----BEGIN CERTIFICATE----- MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2Vy dGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK AoICAQCAEmUXNg7D2wiz0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B 3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2jY0K2dvKpOyuR+OJv0OwWIJAJPuLodMkY tJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFnRghRy4YUVD+8M/5+bJz/ Fp0YvVGONaanZshyZ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1m9/ qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG jjxDah2nGN59PRbxYvnKkKj9 -----END CERTIFICATE----- --- Server certificate subject=CN = ssl0.ovh.net issuer=C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA --- No client certificate CA names sent Peer signing digest: SHA512 Peer signature type: RSA Server Temp Key: X25519, 253 bits --- SSL handshake has read 5698 bytes and written 397 bytes Verification: OK --- New, TLSv1.2, Cipher is ECDHE-RSA-AES256-GCM-SHA384 Server public key is 4096 bit Secure Renegotiation IS supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1.2 Cipher : ECDHE-RSA-AES256-GCM-SHA384 Session-ID: 94C2704B41535450C2E914E258FCF4261AE3830EBAF68050A459650A70DD6AE6 Session-ID-ctx: Master-Key: 78941A4567E592C77B7767DBBC5046B91A108F7B2C7A1ED057C274F8C896337894BD28715CCF43EB981A9832DB147E15 PSK identity: None PSK identity hint: None SRP username: None TLS session ticket lifetime hint: 7200 (seconds) TLS session ticket: 0000 - 7d 83 2f ee 41 40 4d f7-7b 99 ea d7 5f 6e 3b 68 }./.A@M.{..._n;h 0010 - 05 37 73 e7 89 63 2e 0a-ad 25 23 3f 28 d7 3e ed .7s..c...%#?(.>. 0020 - e4 e6 d4 33 52 10 24 49-84 93 7f 33 72 ed 50 20 ...3R.$I...3r.P 0030 - 9b 55 40 21 01 86 99 37-21 78 bc 04 cb 4c 3a c7 .U@!...7!x...L:. 0040 - ee 7a 29 45 d3 d0 88 a2-5c 4a d4 bc 56 54 71 0a .z)E....\J..VTq. 0050 - c4 e6 85 a1 4e 66 2d 46-7e e9 f2 03 63 97 e9 33 ....Nf-F~...c..3 0060 - 1b a7 2c f2 9d da 93 03-bc d7 6b d2 c8 84 13 15 ..,.......k..... 0070 - 46 05 d0 54 ce e5 e8 2a-41 7f 9b 15 a1 00 8a da F..T...*A....... 0080 - ff 8a ce 11 91 83 59 4a-47 be d5 18 da 47 4d a7 ......YJG....GM. 0090 - d4 73 7a 5c 39 a1 21 ac-2b 5e 62 f4 47 ba fc e4 .sz\9.!.+^b.G... 00a0 - e1 06 7d 80 81 53 9e 00-88 c7 13 d2 bc 07 a0 88 ..}..S.......... Start Time: 1592435499 Timeout : 7200 (sec) Verify return code: 0 (ok) Extended master secret: yes --- * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] Dovecot on host 103 ready * BAD Error in IMAP command received by server. * BAD Error in IMAP command received by server. * BYE Too many invalid IMAP commands. closed |
Na końcu komunikacji możemy zobaczyć jakie funkcjonalności ma ten serwer IMAP i możemy po tym nagłówku poznać jakie metody uwierzytelnienia są dostępne dla tego serwera. Poniżej kilka działajacych przykładów wykorzystania IMAPsync dla pojedynczej skrzynki:
Z serwera OVH na własny serwer
1 | ./imapsync --host1 ssl0.ovh.net --port1 993 --user1 test@test.com --password1 haslo123 --host2 mail.etf2l.site --user2 supra@etf2l.site --password2 haslo123 --ssl1 -ssl2 |
Z serwera GMail na własny serwer
1 | ./imapsync --host1 imap.gmail.com --port1 993 --user1 test@gmail.com --password1 haslo123 --host2 mail.etf2l.site --user2 supra@etf2l.site --password2 haslo123 --ssl1 -ssl2 |
Przy przykładzie z GMailem warto zerknąć na informacje dotyczące odblokowywania możliwości synchronizacji poniżej.
Z serwera Politechniki Śląskiej na własny serwer
1 | ./imapsync --host1 poczta.student.polsl.pl --port1 993 --user1 kontostudenckie@student.polsl.pl --password1 haslo123 --host2 mail.etf2l.site --user2 polsl@etf2l.site --password2 haslo --ssl1 -ssl2 |
Z serwera Onet.pl na serwer GMail
Przed synchronizacją należy włączyć obsługę IMAP dla konta oraz „dostęp do mniej bezpiecznych aplikacji”:
Taki problem da się też rozpoznać po logu:
1 2 3 4 5 | Host2 capability before authentication: IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN AUTH=OAUTHBEARER AUTH=XOAUTH AUTH Host2 failure: Error login on [imap.gmail.com] with user [test@gmail.com] auth [LOGIN]: 2 NO [ALERT] Your account is not enabled for IMAP use. Please visit your Gmail settings page and enable your account for IMAP access. (Failure) Exiting with return value 16 (EXIT_AUTHENTICATION_FAILURE) Disconnecting from host1 imap.poczta.onet.pl user1 test@onet.pl Log file is LOG_imapsync/2020_07_23_08_39_05_281_test@onet.pl_test@gmail.com.txt ( to change it, use --logfile filepath ; or use --nolog to turn off logging ) |
Końcowe polecenie jest takie:
1 | ./imapsync --host1 imap.poczta.onet.pl --user1 test@onet.pl --password1 "password123" --host2 imap.gmail.com --port2 993 --user2 test@gmail.com --password2 "password123" --ssl1 -ssl2 |
Przy okazji odpowiedź na pytanie czemu ja zawsze dostaję tak dużo spamu na moją skrzynkę?
– otóż dlatego:
W trakcie rejestracji konta aby mieć skrzynkę za darmo, należy zaznaczyć odpowiednią zgodę, lecz ludzie z reguły nie czytają tego i klikają opcję na samej górze. To powoduje, że Onet.pl i ich partnerzy będą za Waszym przyzwoleniem wysyłać do Was spam. Po kliknięciu Załóż konto jednak przekonuje się, że się myliłem:
Ponadto ich oferta cenowa ze skrzynkami dla prywatnych użytkowników to żart w 2020 roku (np. GMail daje to za darmo (nie do końca, bo mogą zbierać dane o użytkownikach, ale funkcjonalnie i bez spamu za darmo)). Inna rzecz, która mnie zaskoczyła to to, że mogłem zarejestrować konto z jednym z najprostszych haseł słownikowych: Zaq12wsx!
.
Z serwera WP.pl na serwer GMail
W WP.pl jest ta sama śpiewka, co w Onet.pl z mailami marketingowymi i tym, że da się założyć konto z hasłem Zaq12wsx!
, ale przynajmniej Ci zaznaczyli, że te hasło jest kiepskie:
Tutaj podobnie jak w GMail synchronizacja po IMAP jest domyślnie wyłączona, trzeba ją włączyć:
1 2 | Host2 failure: Error login on [imap.wp.pl] with user [test@wp.pl] auth [LOGIN]: 2 NO Wybrany kanal dostepu nalezy aktywowac w intefejsie WWW Exiting with return value 16 (EXIT_AUTHENTICATION_FAILURE) |

1 | ./imapsync --host1 imap.wp.pl --user1 test@wp.pl --password1 "password123" --host2 imap.gmail.com --port2 993 --user2 test@gmail.com --password2 "password123" --ssl1 -ssl2 |
Z serwera Gazeta.pl na serwer GMail
Tutaj spamik ponownie, ale tym razem da się wyłączyć:
Jednak nie zaznaczyło „powyższej” opcji:
Co ciekawe, wg Gazeta.pl Zaq12wsx!
to mocne hasło:
Tutaj jedynie SMTP jest wyłączony (uwaga, gdyby ktoś z tej skrzynki chciał korzystać w Outlooku czy innym kliencie pocztowym). IMAP jest włączony, więc od razu można puścić synchronizację:
1 | ./imapsync --host1 imap.gazeta.pl --user1 test@gazeta.pl --password1 "password123" --host2 imap.gmail.com --port2 993 --user2 test@gmail.com --password2 "password123" --ssl1 -ssl2 |
Z serwera o2.pl na serwer GMail
Interfejs jest identyczny jak ten z WP.pl, te same zgody, te same hasło:
Tak samo jak na WP.pl odpalamy IMAPa:
1 | ./imapsync --host1 poczta.o2.pl --user1 test@o2.pl --password1 "password123" --host2 imap.gmail.com --port2 993 --user2 test@gmail.com --password2 "password123" --ssl1 -ssl2 |
Z własnego serwera na Exchange Online
1 | ./imapsync --host1 ssl0.ovh.net --port1 993 --user1 test@test.com --password1 "password123" --host2 outlook.office365.com --user2 test@test.onmicrosoft.com --password2 "password123" --ssl1 -ssl2 |
Przykład wyniku synchronizacji małej skrzynki:
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | supra@supra-pc:/mnt/r/supra/Pobrane/imapsync-imapsync-1.945$ ./imapsync --host1 ssl0.ovh.net --port1 993 --user1 test@test.com --password1 "password123" --host2 imap.poczta.onet.pl --user2 test@onet.pl --password2 "password123" --ssl1 -ssl2 Here is imapsync 1.945 on host supra-pc, a linux system with 16.5/63.9 free GiB of RAM with Perl 5.26.1 and Mail::IMAPClient 3.42 Transfer started at Thu Jul 23 08:12:33 2020 PID is 38 my PPID is 8 Log file is LOG_imapsync/2020_07_23_08_12_33_744_test@test.com_test@onet.pl.txt ( to change it, use --logfile path ; or use --nolog to turn off logging ) Load is 0.52 0.58 0.59 1/5 on 16 cores Current directory is /mnt/r/supra/Pobrane/imapsync-imapsync-1.945 Real user id is supra (uid 1000) Effective user id is supra (euid 1000) $RCSfile: imapsync,v $ $Revision: 1.945 $ $Date: 2019/06/26 19:30:56 $ Command line used, run by /usr/bin/perl: ./imapsync --host1 ssl0.ovh.net --port1 993 --user1 test@test.com --password1 MASKED --host2 imap.poczta.onet.pl --user2 test@onet.pl --password2 MASKED --ssl1 -ssl2 Temp directory is /tmp ( to change it use --tmpdir dirpath ) kill -QUIT 38 # special behavior: call to sub catch_exit kill -TERM 38 # special behavior: call to sub catch_exit kill -INT 38 # special behavior: call to sub catch_reconnect kill -HUP 38 # special behavior: call to sub catch_print kill -USR1 38 # special behavior: call to sub toggle_sleep File /tmp/imapsync.pid does not exist PID file is /tmp/imapsync.pid ( to change it, use --pidfile filepath ; to avoid it use --pidfile "" ) Writing my PID 38 in /tmp/imapsync.pid Writing also my logfile name in /tmp/imapsync.pid : LOG_imapsync/2020_07_23_08_12_33_744_test@test.com_test@onet.pl.txt Modules version list: Authen::NTLM 1.09 CGI 4.49 Compress::Zlib 2.074 Crypt::OpenSSL::RSA 0.28 Data::Uniqid 0.12 Digest::HMAC_MD5 1.01 Digest::HMAC_SHA1 1.03 Digest::MD5 2.55 File::Copy::Recursive 0.40 File::Spec 3.67 Getopt::Long 2.49 HTML::Entities 3.69 IO::Socket 1.38 IO::Socket::INET 1.35 IO::Socket::INET6 2.72 IO::Socket::IP 0.38 IO::Socket::SSL 2.060 IO::Tee 0.65 JSON 4.02 JSON::WebToken 0.10 LWP 6.31 Mail::IMAPClient 3.42 Net::Ping 2.55 Net::SSLeay 1.84 Term::ReadKey 2.37 Test::MockObject 1.20161202 Time::HiRes 1.9741 URI::Escape 3.31 Unicode::String 2.10 ( use --no-modulesversion to turn off printing this Perl modules list ) Info: will resync flags for already transferred messages. Use --noresyncflags to not resync flags. SSL debug mode level is --debugssl 1 (can be set from 0 meaning no debug to 4 meaning max debug) Host1: SSL default mode is like --sslargs1 "SSL_verify_mode=0", meaning for host1 SSL_VERIFY_NONE, ie, do not check the certificate server. Host1: Use --sslargs1 SSL_verify_mode=1 to have SSL_VERIFY_PEER, ie, check the certificate server of host1 Host2: SSL default mode is like --sslargs2 "SSL_verify_mode=0", meaning for host2 SSL_VERIFY_NONE, ie, do not check the certificate server. Host2: Use --sslargs2 SSL_verify_mode=1 to have SSL_VERIFY_PEER, ie, check the certificate server of host2 Info: turned ON syncinternaldates, will set the internal dates (arrival dates) on host2 same as host1. Host1: will try to use LOGIN authentication on host1 Host2: will try to use LOGIN authentication on host2 Host1: imap connection timeout is 120 seconds Host2: imap connection timeout is 120 seconds Host1: IMAP server [ssl0.ovh.net] port [993] user [test@test.com] Host2: IMAP server [imap.poczta.onet.pl] port [993] user [test@onet.pl] Host1: connecting and login on host1 [ssl0.ovh.net] port [993] with user [test@test.com] Host1 IP address: 193.70.18.144 Host1 banner: * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] Dovecot on host 103 ready Host1 capability before authentication: IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN AUTH Host1: ssl0.ovh.net says it has CAPABILITY for AUTHENTICATE LOGIN Host1: success login on [ssl0.ovh.net] with user [test@test.com] auth [LOGIN] Host2: connecting and login on host2 [imap.poczta.onet.pl] port [993] with user [test@onet.pl] Host2 IP address: 213.180.147.154 Host2 banner: * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID SORT SORT=DISPLAY MULTIAPPEND UNSELECT CHILDREN UIDPLUS LIST-STATUS LIST-EXTENDED I18NLEVEL=1 SEARCHRES WITHIN AUTH=PLAIN AUTH=LOGIN AUTH=XOAUTH2] Onet server ready. Host2 capability before authentication: IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID SORT SORT=DISPLAY MULTIAPPEND UNSELECT CHILDREN UIDPLUS LIST-STATUS LIST-EXTENDED I18NLEVEL=1 SEARCHRES WITHIN AUTH=PLAIN AUTH=LOGIN AUTH=XOAUTH2 I18NLEVEL AUTH Host2: imap.poczta.onet.pl says it has CAPABILITY for AUTHENTICATE LOGIN Host2: success login on [imap.poczta.onet.pl] with user [test@onet.pl] auth [LOGIN] Host1: state Authenticated Host2: state Authenticated Host1 capability once authenticated: IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE QUOTA THREAD I18NLEVEL CONTEXT Host2 capability once authenticated: IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID SORT SORT=DISPLAY MULTIAPPEND UNSELECT CHILDREN UIDPLUS LIST-STATUS LIST-EXTENDED I18NLEVEL=1 SEARCHRES WITHIN I18NLEVEL Host1: found ID capability. Sending/receiving ID, presented in raw IMAP for now. In order to avoid sending/receiving ID, use option --noid Sending: 4 ID ("name" "imapsync" "version" "1.945" "os" "linux" "vendor" "Gilles LAMIRAL" "support-url" "https://imapsync.lamiral.info/" "date" "26-Jun-2019 19:30:56 +0000" "side" "host1") Sent 181 bytes Read: * ID ("name" "Dovecot") 4 OK ID completed (0.000 + 0.000 secs). Host2: found ID capability. Sending/receiving ID, presented in raw IMAP for now. In order to avoid sending/receiving ID, use option --noid Sending: 4 ID ("name" "imapsync" "version" "1.945" "os" "linux" "vendor" "Gilles LAMIRAL" "support-url" "https://imapsync.lamiral.info/" "date" "26-Jun-2019 19:30:56 +0000" "side" "host2") Sent 181 bytes Read: * ID ("name" "NIL") 4 OK ID completed (0.001 + 0.000 secs). Host1: found 13 folders. Host2: found 8 folders. Host1: guessing separator from folder listing: [.] Host1: separator given by NAMESPACE: [.] Host2: guessing separator from folder listing: [/] Host2: No NAMESPACE capability, so using guessed separator [/] You can set the separator character with the --sep2 option, the complete listing of folders may help you to find it [Powiadomienia] [Oferty] [Spo&AUI-eczno&AVs-ci] [Drafts] [Junk] [Sent] [Trash] [INBOX] Host1: guessing prefix from folder listing: [INBOX.] Host1: prefix given by NAMESPACE: [INBOX.] Host2: guessing prefix from folder listing: [] Host2: No NAMESPACE capability so using guessed prefix [] You can set the prefix namespace with the --prefix2 option, the folowing listing of folders may help you to find it: [Powiadomienia] [Oferty] [Spo&AUI-eczno&AVs-ci] [Drafts] [Junk] [Sent] [Trash] [INBOX] Host1: separator and prefix: [.][INBOX.] Host2: separator and prefix: [/][] Including all folders found by default. Use --subscribed or --folder or --folderrec or --include to select specific folders. Use --exclude to unselect specific folders. Host1: Checking wanted folders exist. Use --nocheckfoldersexist to avoid this check (shared of public namespace targeted). Host1: Checking wanted folders are selectable. Use --nocheckselectable to avoid this check. Turned off automapping folders ( use --automap to turn on automapping ) ++++ Listing folders All foldernames are presented between brackets like [X] where X is the foldername. When a foldername contains non-ASCII characters it is presented in the form [X] = [Y] where X is the imap foldername you have to use in command line options and Y is the utf8 output just printed for convenience, to recognize it. Host1: folders list (first the raw imap format then the [X] = [Y]): * LIST (\HasChildren) "." INBOX * LIST (\HasNoChildren) "." "INBOX.ESET Antispam" * LIST (\HasNoChildren) "." INBOX.INBOX.Sent * LIST (\HasNoChildren) "." INBOX.INBOX.Junk * LIST (\HasNoChildren) "." INBOX.INBOX.Drafts * LIST (\HasNoChildren) "." INBOX.INBOX.Trash * LIST (\HasNoChildren) "." INBOX.Trash * LIST (\HasNoChildren) "." INBOX.Wiadomo&AVs-ci-&AVs-mieci * LIST (\HasNoChildren) "." "INBOX.Elementy wys&AUI-ane" * LIST (\HasNoChildren) "." INBOX.Sent * LIST (\HasNoChildren) "." "INBOX.Elementy usuni&ARk-te" * LIST (\HasNoChildren) "." "INBOX.Wersje robocze" * LIST (\HasNoChildren) "." "INBOX.Wykryte elementy" 22 OK List completed (0.000 + 0.000 secs). [INBOX] [INBOX.ESET Antispam] [INBOX.Elementy usuni&ARk-te] = [INBOX.Elementy usunięte] [INBOX.Elementy wys&AUI-ane] = [INBOX.Elementy wysłane] [INBOX.INBOX.Drafts] [INBOX.INBOX.Junk] [INBOX.INBOX.Sent] [INBOX.INBOX.Trash] [INBOX.Sent] [INBOX.Trash] [INBOX.Wersje robocze] [INBOX.Wiadomo&AVs-ci-&AVs-mieci] = [INBOX.Wiadomości-śmieci] [INBOX.Wykryte elementy] Host2: folders list (first the raw imap format then the [X] = [Y]): * LIST (\NoInferiors) "/" Powiadomienia * LIST (\NoInferiors) "/" Oferty * LIST (\NoInferiors) "/" Spo&AUI-eczno&AVs-ci * LIST (\NoInferiors) "/" Drafts * LIST (\NoInferiors) "/" Junk * LIST (\NoInferiors) "/" Sent * LIST (\NoInferiors) "/" Trash * LIST (\NoInferiors) "/" INBOX 9 OK List completed (0.001 + 0.000 secs). [Drafts] [INBOX] [Junk] [Oferty] [Powiadomienia] [Sent] [Spo&AUI-eczno&AVs-ci] = [Społeczności] [Trash] Folders in host2 not in host1: [Spo&AUI-eczno&AVs-ci] = [Społeczności] [Powiadomienia] [Oferty] [Junk] [Drafts] Folders sizes before the synchronization. You can remove foldersizes listings by using "--nofoldersizes" and "--nofoldersizesatend" but then you will also lose the ETA (Estimation Time of Arrival) given after each message copy. ++++ Calculating sizes of 13 folders on Host1 Host1 folder 1/13 [INBOX] Size: 42026 Messages: 8 Biggest: 7928 Host1 folder 2/13 [INBOX.ESET Antispam] Size: 0 Messages: 0 Biggest: 0 Host1 folder 3/13 [INBOX.Elementy usuni&ARk-te] = [INBOX.Elementy usunięte] Size: 0 Messages: 0 Biggest: 0 Host1 folder 4/13 [INBOX.Elementy wys&AUI-ane] = [INBOX.Elementy wysłane] Size: 3211 Messages: 1 Biggest: 3211 Host1 folder 5/13 [INBOX.INBOX.Drafts] Size: 0 Messages: 0 Biggest: 0 Host1 folder 6/13 [INBOX.INBOX.Junk] Size: 0 Messages: 0 Biggest: 0 Host1 folder 7/13 [INBOX.INBOX.Sent] Size: 663 Messages: 1 Biggest: 663 Host1 folder 8/13 [INBOX.INBOX.Trash] Size: 0 Messages: 0 Biggest: 0 Host1 folder 9/13 [INBOX.Sent] Size: 0 Messages: 0 Biggest: 0 Host1 folder 10/13 [INBOX.Trash] Size: 5718 Messages: 1 Biggest: 5718 Host1 folder 11/13 [INBOX.Wersje robocze] Size: 0 Messages: 0 Biggest: 0 Host1 folder 12/13 [INBOX.Wiadomo&AVs-ci-&AVs-mieci] = [INBOX.Wiadomości-śmieci] Size: 0 Messages: 0 Biggest: 0 Host1 folder 13/13 [INBOX.Wykryte elementy] Size: 0 Messages: 0 Biggest: 0 Host1 Nb folders: 13 folders Host1 Nb messages: 11 messages Host1 Total size: 51618 bytes (50.408 KiB) Host1 Biggest message: 7928 bytes (7.742 KiB) Host1 Time spent: 3.7 seconds ++++ Calculating sizes of 13 folders on Host2 Host2 folder 1/13 [ESET Antispam] does not exist yet Host2 folder 2/13 [Elementy usuni&ARk-te] = [Elementy usunięte] does not exist yet Host2 folder 3/13 [Elementy wys&AUI-ane] = [Elementy wysłane] does not exist yet Host2 folder 4/13 [INBOX] Size: 286065 Messages: 2 Biggest: 231514 Host2 folder 5/13 [INBOX/Drafts] does not exist yet Host2 folder 6/13 [INBOX/Junk] does not exist yet Host2 folder 7/13 [INBOX/Sent] does not exist yet Host2 folder 8/13 [INBOX/Trash] does not exist yet Host2 folder 9/13 [Sent] Size: 0 Messages: 0 Biggest: 0 Host2 folder 10/13 [Trash] Size: 0 Messages: 0 Biggest: 0 Host2 folder 11/13 [Wersje robocze] does not exist yet Host2 folder 12/13 [Wiadomo&AVs-ci-&AVs-mieci] = [Wiadomości-śmieci] does not exist yet Host2 folder 13/13 [Wykryte elementy] does not exist yet Host2 Nb folders: 13 folders Host2 Nb messages: 2 messages Host2 Total size: 286065 bytes (279.360 KiB) Host2 Biggest message: 231514 bytes (226.088 KiB) Host2 Time spent: 0.1 seconds ++++ Looping on each one of 13 folders to sync Folder 1/13 [INBOX] -> [INBOX] Host1: folder [INBOX] has 8 messages in total (mentioned by SELECT) Host2: folder [INBOX] has 2 messages in total (mentioned by SELECT) Host2: folder [INBOX] permanentflags: Host1: folder [INBOX] considering 8 messages Host2: folder [INBOX] considering 2 messages Host1: folder [INBOX] selected 8 messages, duplicates 0 Host2: INBOX/1 size 54569 ignored (no wanted headers so we ignore this message) Host2: folder [INBOX] selected 2 messages, duplicates 0 msg INBOX/1 {6599} copied to INBOX/3 1.00 msgs/s 6.444 KiB/s 6.444 KiB copied ETA: Thu Jul 23 08:12:48 2020 10 s 10/11 msgs left msg INBOX/2 {4128} copied to INBOX/4 2.00 msgs/s 10.476 KiB/s 10.476 KiB copied ETA: Thu Jul 23 08:12:42 2020 4 s 9/11 msgs left msg INBOX/4 {4152} copied to INBOX/5 3.00 msgs/s 14.530 KiB/s 14.530 KiB copied ETA: Thu Jul 23 08:12:41 2020 3 s 8/11 msgs left msg INBOX/5 {4711} copied to INBOX/6 3.87 msgs/s 18.503 KiB/s 19.131 KiB copied ETA: Thu Jul 23 08:12:40 2020 2 s 7/11 msgs left msg INBOX/6 {5690} copied to INBOX/7 4.22 msgs/s 20.858 KiB/s 24.688 KiB copied ETA: Thu Jul 23 08:12:40 2020 1 s 6/11 msgs left msg INBOX/7 {3635} copied to INBOX/8 4.42 msgs/s 20.812 KiB/s 28.237 KiB copied ETA: Thu Jul 23 08:12:40 2020 1 s 5/11 msgs left msg INBOX/8 {7928} copied to INBOX/9 4.65 msgs/s 23.916 KiB/s 35.979 KiB copied ETA: Thu Jul 23 08:12:39 2020 1 s 4/11 msgs left msg INBOX/9 {5183} copied to INBOX/10 4.81 msgs/s 24.685 KiB/s 41.041 KiB copied ETA: Thu Jul 23 08:12:39 2020 1 s 3/11 msgs left Folder 2/13 [INBOX.ESET Antispam] -> [ESET Antispam] Host1: folder [INBOX.ESET Antispam] has 0 messages in total (mentioned by SELECT) Creating folder [ESET Antispam] on host2 Created folder [ESET Antispam] on host2 Host2: folder [ESET Antispam] has 0 messages in total (mentioned by SELECT) Host2: folder [ESET Antispam] permanentflags: Host2: Subscribing to folder ESET Antispam Host1: folder [INBOX.ESET Antispam] considering 0 messages Host2: folder [ESET Antispam] considering 0 messages Host1: folder [INBOX.ESET Antispam] selected 0 messages, duplicates 0 Host2: folder [ESET Antispam] selected 0 messages, duplicates 0 Folder 3/13 [INBOX.Elementy usuni&ARk-te] = [INBOX.Elementy usunięte] -> [Elementy usuni&ARk-te] = [Elementy usunięte] Host1: folder [INBOX.Elementy usuni&ARk-te] has 0 messages in total (mentioned by SELECT) Creating folder [Elementy usuni&ARk-te] on host2 Folder [Elementy usuni&ARk-te] already exists (--nomixfolders is not set) Host2: folder [Elementy usuni&ARk-te] has 0 messages in total (mentioned by SELECT) Host2: folder [Elementy usuni&ARk-te] permanentflags: Host2: Subscribing to folder Elementy usuni&ARk-te Host1: folder [INBOX.Elementy usuni&ARk-te] considering 0 messages Host2: folder [Elementy usuni&ARk-te] considering 0 messages Host1: folder [INBOX.Elementy usuni&ARk-te] selected 0 messages, duplicates 0 Host2: folder [Elementy usuni&ARk-te] selected 0 messages, duplicates 0 Folder 4/13 [INBOX.Elementy wys&AUI-ane] = [INBOX.Elementy wysłane] -> [Elementy wys&AUI-ane] = [Elementy wysłane] Host1: folder [INBOX.Elementy wys&AUI-ane] has 1 messages in total (mentioned by SELECT) Creating folder [Elementy wys&AUI-ane] on host2 Folder [Elementy wys&AUI-ane] already exists (--nomixfolders is not set) Host2: folder [Elementy wys&AUI-ane] has 0 messages in total (mentioned by SELECT) Host2: folder [Elementy wys&AUI-ane] permanentflags: Host2: Subscribing to folder Elementy wys&AUI-ane Host1: folder [INBOX.Elementy wys&AUI-ane] considering 1 messages Host2: folder [Elementy wys&AUI-ane] considering 0 messages Host1: folder [INBOX.Elementy wys&AUI-ane] selected 1 messages, duplicates 0 Host2: folder [Elementy wys&AUI-ane] selected 0 messages, duplicates 0 msg INBOX.Elementy wys&AUI-ane/1 {3211} copied to Elementy wys&AUI-ane/1 3.55 msgs/s 17.422 KiB/s 44.177 KiB copied ETA: Thu Jul 23 08:12:40 2020 1 s 2/11 msgs left Folder 5/13 [INBOX.INBOX.Drafts] -> [INBOX/Drafts] Host1: folder [INBOX.INBOX.Drafts] has 0 messages in total (mentioned by SELECT) Creating folder [INBOX/Drafts] on host2 Created folder [INBOX/Drafts] on host2 Host2 folder INBOX/Drafts: Could not select: 54 NO Mailbox doesn't exist: INBOX/Drafts (0.003 + 0.000 + 0.002 secs). Creating folder [INBOX/Drafts] on host2 Created folder [INBOX/Drafts] on host2 Host2 folder INBOX/Drafts: Could not select: 58 NO Mailbox doesn't exist: INBOX/Drafts (0.003 + 0.000 + 0.002 secs). Folder 6/13 [INBOX.INBOX.Junk] -> [INBOX/Junk] Host1: folder [INBOX.INBOX.Junk] has 0 messages in total (mentioned by SELECT) Creating folder [INBOX/Junk] on host2 Created folder [INBOX/Junk] on host2 Host2 folder INBOX/Junk: Could not select: 62 NO Mailbox doesn't exist: INBOX/Junk (0.003 + 0.000 + 0.002 secs). Creating folder [INBOX/Junk] on host2 Created folder [INBOX/Junk] on host2 Host2 folder INBOX/Junk: Could not select: 66 NO Mailbox doesn't exist: INBOX/Junk (0.002 + 0.000 + 0.001 secs). Folder 7/13 [INBOX.INBOX.Sent] -> [INBOX/Sent] Host1: folder [INBOX.INBOX.Sent] has 1 messages in total (mentioned by SELECT) Creating folder [INBOX/Sent] on host2 Created folder [INBOX/Sent] on host2 Host2 folder INBOX/Sent: Could not select: 70 NO Mailbox doesn't exist: INBOX/Sent (0.002 + 0.000 + 0.001 secs). Creating folder [INBOX/Sent] on host2 Created folder [INBOX/Sent] on host2 Host2 folder INBOX/Sent: Could not select: 74 NO Mailbox doesn't exist: INBOX/Sent (0.002 + 0.000 + 0.001 secs). Folder 8/13 [INBOX.INBOX.Trash] -> [INBOX/Trash] Host1: folder [INBOX.INBOX.Trash] has 0 messages in total (mentioned by SELECT) Creating folder [INBOX/Trash] on host2 Created folder [INBOX/Trash] on host2 Host2 folder INBOX/Trash: Could not select: 78 NO Mailbox doesn't exist: INBOX/Trash (0.002 + 0.000 + 0.001 secs). Creating folder [INBOX/Trash] on host2 Created folder [INBOX/Trash] on host2 Host2 folder INBOX/Trash: Could not select: 82 NO Mailbox doesn't exist: INBOX/Trash (0.002 + 0.000 + 0.001 secs). Folder 9/13 [INBOX.Sent] -> [Sent] Host1: folder [INBOX.Sent] has 0 messages in total (mentioned by SELECT) Host2: folder [Sent] has 1 messages in total (mentioned by SELECT) Host2: folder [Sent] permanentflags: Host1: folder [INBOX.Sent] considering 0 messages Host2: folder [Sent] considering 1 messages Host1: folder [INBOX.Sent] selected 0 messages, duplicates 0 Host2: folder [Sent] selected 1 messages, duplicates 0 Folder 10/13 [INBOX.Trash] -> [Trash] Host1: folder [INBOX.Trash] has 1 messages in total (mentioned by SELECT) Host2: folder [Trash] has 0 messages in total (mentioned by SELECT) Host2: folder [Trash] permanentflags: Host1: folder [INBOX.Trash] considering 1 messages Host2: folder [Trash] considering 0 messages Host1: folder [INBOX.Trash] selected 1 messages, duplicates 0 Host2: folder [Trash] selected 0 messages, duplicates 0 msg INBOX.Trash/1 {5718} copied to Trash/1 2.53 msgs/s 12.601 KiB/s 49.761 KiB copied ETA: Thu Jul 23 08:12:41 2020 0 s 1/11 msgs left Folder 11/13 [INBOX.Wersje robocze] -> [Wersje robocze] Host1: folder [INBOX.Wersje robocze] has 0 messages in total (mentioned by SELECT) Creating folder [Wersje robocze] on host2 Created folder [Wersje robocze] on host2 Host2: folder [Wersje robocze] has 0 messages in total (mentioned by SELECT) Host2: folder [Wersje robocze] permanentflags: Host2: Subscribing to folder Wersje robocze Host1: folder [INBOX.Wersje robocze] considering 0 messages Host2: folder [Wersje robocze] considering 0 messages Host1: folder [INBOX.Wersje robocze] selected 0 messages, duplicates 0 Host2: folder [Wersje robocze] selected 0 messages, duplicates 0 Folder 12/13 [INBOX.Wiadomo&AVs-ci-&AVs-mieci] = [INBOX.Wiadomości-śmieci] -> [Wiadomo&AVs-ci-&AVs-mieci] = [Wiadomości-śmieci] Host1: folder [INBOX.Wiadomo&AVs-ci-&AVs-mieci] has 0 messages in total (mentioned by SELECT) Creating folder [Wiadomo&AVs-ci-&AVs-mieci] on host2 Folder [Wiadomo&AVs-ci-&AVs-mieci] already exists (--nomixfolders is not set) Host2: folder [Wiadomo&AVs-ci-&AVs-mieci] has 0 messages in total (mentioned by SELECT) Host2: folder [Wiadomo&AVs-ci-&AVs-mieci] permanentflags: Host2: Subscribing to folder Wiadomo&AVs-ci-&AVs-mieci Host1: folder [INBOX.Wiadomo&AVs-ci-&AVs-mieci] considering 0 messages Host2: folder [Wiadomo&AVs-ci-&AVs-mieci] considering 0 messages Host1: folder [INBOX.Wiadomo&AVs-ci-&AVs-mieci] selected 0 messages, duplicates 0 Host2: folder [Wiadomo&AVs-ci-&AVs-mieci] selected 0 messages, duplicates 0 Folder 13/13 [INBOX.Wykryte elementy] -> [Wykryte elementy] Host1: folder [INBOX.Wykryte elementy] has 0 messages in total (mentioned by SELECT) Creating folder [Wykryte elementy] on host2 Created folder [Wykryte elementy] on host2 Host2: folder [Wykryte elementy] has 0 messages in total (mentioned by SELECT) Host2: folder [Wykryte elementy] permanentflags: Host2: Subscribing to folder Wykryte elementy Host1: folder [INBOX.Wykryte elementy] considering 0 messages Host2: folder [Wykryte elementy] considering 0 messages Host1: folder [INBOX.Wykryte elementy] selected 0 messages, duplicates 0 Host2: folder [Wykryte elementy] selected 0 messages, duplicates 0 ++++ End looping on each folder Folders sizes after the synchronization. You can remove this foldersizes listing by using "--nofoldersizesatend" ++++ Calculating sizes of 13 folders on Host1 Host1 folder 1/13 [INBOX] Size: 42026 Messages: 8 Biggest: 7928 Host1 folder 2/13 [INBOX.ESET Antispam] Size: 0 Messages: 0 Biggest: 0 Host1 folder 3/13 [INBOX.Elementy usuni&ARk-te] = [INBOX.Elementy usunięte] Size: 0 Messages: 0 Biggest: 0 Host1 folder 4/13 [INBOX.Elementy wys&AUI-ane] = [INBOX.Elementy wysłane] Size: 3211 Messages: 1 Biggest: 3211 Host1 folder 5/13 [INBOX.INBOX.Drafts] Size: 0 Messages: 0 Biggest: 0 Host1 folder 6/13 [INBOX.INBOX.Junk] Size: 0 Messages: 0 Biggest: 0 Host1 folder 7/13 [INBOX.INBOX.Sent] Size: 663 Messages: 1 Biggest: 663 Host1 folder 8/13 [INBOX.INBOX.Trash] Size: 0 Messages: 0 Biggest: 0 Host1 folder 9/13 [INBOX.Sent] Size: 0 Messages: 0 Biggest: 0 Host1 folder 10/13 [INBOX.Trash] Size: 5718 Messages: 1 Biggest: 5718 Host1 folder 11/13 [INBOX.Wersje robocze] Size: 0 Messages: 0 Biggest: 0 Host1 folder 12/13 [INBOX.Wiadomo&AVs-ci-&AVs-mieci] = [INBOX.Wiadomości-śmieci] Size: 0 Messages: 0 Biggest: 0 Host1 folder 13/13 [INBOX.Wykryte elementy] Size: 0 Messages: 0 Biggest: 0 Host1 Nb folders: 13 folders Host1 Nb messages: 11 messages Host1 Total size: 51618 bytes (50.408 KiB) Host1 Biggest message: 7928 bytes (7.742 KiB) Host1 Time spent: 1.5 seconds ++++ Calculating sizes of 13 folders on Host2 Host2 folder 1/13 [ESET Antispam] Size: 0 Messages: 0 Biggest: 0 Host2 folder 2/13 [Elementy usuni&ARk-te] = [Elementy usunięte] does not exist yet Host2 folder 3/13 [Elementy wys&AUI-ane] = [Elementy wysłane] does not exist yet Host2 folder 4/13 [INBOX] Size: 328475 Messages: 10 Biggest: 231514 Host2 folder 5/13 [INBOX/Drafts] does not exist yet Host2 folder 6/13 [INBOX/Junk] does not exist yet Host2 folder 7/13 [INBOX/Sent] does not exist yet Host2 folder 8/13 [INBOX/Trash] does not exist yet Host2 folder 9/13 [Sent] Size: 3259 Messages: 1 Biggest: 3259 Host2 folder 10/13 [Trash] Size: 5766 Messages: 1 Biggest: 5766 Host2 folder 11/13 [Wersje robocze] Size: 0 Messages: 0 Biggest: 0 Host2 folder 12/13 [Wiadomo&AVs-ci-&AVs-mieci] = [Wiadomości-śmieci] does not exist yet Host2 folder 13/13 [Wykryte elementy] Size: 0 Messages: 0 Biggest: 0 Host2 Nb folders: 13 folders Host2 Nb messages: 12 messages Host2 Total size: 337500 bytes (329.590 KiB) Host2 Biggest message: 231514 bytes (226.088 KiB) Host2 Time spent: 0.2 seconds ++++ Statistics Transfer started on : Thu Jul 23 08:12:33 2020 Transfer ended on : Thu Jul 23 08:12:43 2020 Transfer time : 10.1 sec Folders synced : 13/13 synced Messages transferred : 10 Messages skipped : 0 Messages found duplicate on host1 : 0 Messages found duplicate on host2 : 0 Messages found crossduplicate on host2 : 0 Messages void (noheader) on host1 : 0 Messages void (noheader) on host2 : 1 Messages found in host1 not in host2 : 0 messages Messages found in host2 not in host1 : 1 messages Messages deleted on host1 : 0 Messages deleted on host2 : 0 Total bytes transferred : 50955 (49.761 KiB) Total bytes skipped : 0 (0.000 KiB) Message rate : 1.0 messages/s Average bandwidth rate : 4.9 KiB/s Reconnections to host1 : 0 Reconnections to host2 : 0 Memory consumption at the end : 188.4 MiB (started with 170.5 MiB) Load end is : 0.52 0.58 0.59 1/5 on 16 cores Biggest message : 7928 bytes (7.742 KiB) Memory/biggest message ratio : 24916.5 Start difference host2 - host1 : -9 messages, 234447 bytes (228.952 KiB) Final difference host2 - host1 : 1 messages, 285882 bytes (279.182 KiB) The sync looks good, all 10 identified messages in host1 are on host2. The sync is not strict, there are 1 messages in host2 that are not on host1. Use --delete2 to delete them and have a strict sync. Detected 8 errors Check if a new imapsync release is available by adding --releasecheck Homepage: https://imapsync.lamiral.info/ ++++ Listing 8 errors encountered during the sync ( avoid this listing with --noerrorsdump ). Err 1/8: Host2 folder INBOX/Drafts: Could not select: 54 NO Mailbox doesn't exist: INBOX/Drafts (0.003 + 0.000 + 0.002 secs). Err 2/8: Host2 folder INBOX/Drafts: Could not select: 58 NO Mailbox doesn't exist: INBOX/Drafts (0.003 + 0.000 + 0.002 secs). Err 3/8: Host2 folder INBOX/Junk: Could not select: 62 NO Mailbox doesn't exist: INBOX/Junk (0.003 + 0.000 + 0.002 secs). Err 4/8: Host2 folder INBOX/Junk: Could not select: 66 NO Mailbox doesn't exist: INBOX/Junk (0.002 + 0.000 + 0.001 secs). Err 5/8: Host2 folder INBOX/Sent: Could not select: 70 NO Mailbox doesn't exist: INBOX/Sent (0.002 + 0.000 + 0.001 secs). Err 6/8: Host2 folder INBOX/Sent: Could not select: 74 NO Mailbox doesn't exist: INBOX/Sent (0.002 + 0.000 + 0.001 secs). Err 7/8: Host2 folder INBOX/Trash: Could not select: 78 NO Mailbox doesn't exist: INBOX/Trash (0.002 + 0.000 + 0.001 secs). Err 8/8: Host2 folder INBOX/Trash: Could not select: 82 NO Mailbox doesn't exist: INBOX/Trash (0.002 + 0.000 + 0.001 secs). Exiting with return value 111 (EXIT_WITH_ERRORS) Log file is LOG_imapsync/2020_07_23_08_12_33_744_test@test.com_test@onet.pl.txt ( to change it, use --logfile filepath ; or use --nolog to turn off logging ) |
Nie znalazłem rozwiązania na błędy, które pojawiają się na samym końcu, więc jeśli ktoś zna rozwiązanie – chętnie o tym posłucham.
Exchange i przenoszenie wielu skrzynek na inny serwer
Tutaj sprawa jest nieco skomplikowana: Exchange domyślnie nie obsługuje IMAPa, to znaczy ta funkcja jest wyłączona. Trzeba ją włączyć i skonfigurować dla użytkowników. Jeśli chodzi o synchronizację wielu użytkowników – niczym się nie różni w stosunku tego, co jest powyżej, poza tym, że robimy to dla wielu użytkowników i czytamy loginy i hasła kont źródłowych i docelowych z pliku CSV. Testy robiłem na Exchange 2019 i do niego będę się odnosił. Nazwa serwera mailowego to mail.serba.website
. Poza tym, co wspomniałem, konta muszą być wcześniej utworzone na docelowym serwerze, na który przenosimy skrzynki.
Instrukcja włączania IMAPa jest tutaj, ale ja ją skrócę – poniższe usługi trzeba włączyć i zmienić ich tryb na Automatyczny:
Następnie należy ustawić adres FQDN dla serwera IMAP Exchange’a:
1 2 | C:\Windows\system32> Set-ImapSettings -ExternalConnectionSettings "mail.serba.website:993:SSL" , "mail.serba.website:143:TLS" -X509CertificateName mail.serba.website WARNING: Changes to IMAP4 settings will only take effect after all Microsoft Exchange IMAP4 services are restarted on server EXCHANGE. |
Po tym należy wykonać restart usługi:
01 02 03 04 05 06 07 08 09 10 11 | [PS] C:\Windows\system32> Restart-Service MSExchangeIMAP4; Restart-Service MSExchangeIMAP4BE WARNING: Waiting for service 'Microsoft Exchange IMAP4 (MSExchangeIMAP4)' to start... WARNING: Waiting for service 'Microsoft Exchange IMAP4 (MSExchangeIMAP4)' to start... WARNING: Waiting for service 'Microsoft Exchange IMAP4 Backend (MSExchangeIMAP4BE)' to start... WARNING: Waiting for service 'Microsoft Exchange IMAP4 Backend (MSExchangeIMAP4BE)' to start... [PS] C:\Windows\system32> Get-Service MSExchangeIMAP4; Get-Service MSExchangeIMAP4BE Status Name DisplayName ------ ---- ----------- Running MSExchangeIMAP4 Microsoft Exchange IMAP4 Running MSExchangeIMAP4BE Microsoft Exchange IMAP4 Backend |
Po tym IMAP działa, ale nie można zapomnieć o tym, by ten miał ważny certyfikat SSL lub jeśli ma samopodpisany lub nieważny, należy użyć opcji --sslargs2 SSL_verify_mode=0
zakładając, że Exchange jest serwerem na który przenosimy skrzynki.
Następnie należy przygotować skrypt, który wykona nam synchronizację oraz plik CSV zawierający loginy i hasła. CSV wygląda tak (zapisany jako konta.csv
):
1 2 3 | konto1@test.com;haslo1;apilecki@website;haslo1 konto2@test.com;haslo2;bpoprawa@website;haslo2 konto3@test.com;haslo3;fkluk@website;haslo3 |
Skrypt wygląda tak:
1 2 3 4 | { while IFS= ';' read u1 p1 u2 p2; do /mnt/c/Users/Administrator .SERBA /Desktop/imapsync/imapsync --host1 ssl0.ovh.net --user1 "$u1" --password1 "$p1" --ssl1 --port1 993 \ --host2 exchange.serba. local --user2 "$u2" --password2 "$p2" -ssl2 done ; } < konta.csv |
Oczywiście należy podmienić ścieżkę do imapsync na właściwą wcześniej, po tym zapisujemy skrypt jako sync.sh
i wykonujemy polecenie bash sync.sh
. Po tym skrzynki się zsynchronizują.
Kwestie wydajnościowe
Według zaleceń twórcy IMAPsynca są kwestie, które trzeba wziąć pod uwagę pod kątem synchronizacji i myślę, przy masowych synchronizacjach warto wziąć pod uwagę. Jeśli mamy dużo kont do synchronizacji to można podzielić plik CSV na mniejsze i odpalić osobne procesy dla każdego pliku CSV – w ten sposób więcej synchronizacji można wykonać w jednym czasie, lecz nie ma dokładnego określenia ile ich ma być. Pozostaje testować. Poza tym, warto takie synchronizacje robić z poziomu źródłowego serwera pocztowego lub z docelowego serwera pocztowego (jeśli to jest w ogóle możliwe). To zapewni nam najlepszą wydajność, na przykład jeśli wysyłamy skrzynkę do Office 365 z lokalnego Exchange, warto taki program odpalić bezpośrednio na Exchange’u (jeśli to w ogóle możliwe),
Bardzo przydatny materiał. Nie znam Linux, więc nie wiem co zrobić po przeczytaniu „… można wrócić do głównego katalogu sklonowanego repozytorium Gita i zanim odpalimy IMAPsync warto sprawdzić dane do serwera pocztowego…..”
Niestety, ja potrzebuje screen umożliwiające dotarcie do pliku, w którym mógłbym zmieniać dane dostępowe do serwerów pocztowych. Dodam, że korzystam z Imapsync na Linux Subsystem for Windows (WSL).
hej, dzięki
W tym poradnik też używałem WSL.
„można wrócić do głównego katalogu sklonowanego repozytorium Gita” – gdy wykonujesz operację git clone, kopiujesz zawartość całego repozytorium z GitHuba na przestrzeń lokalną (najprawdopodobniej) swojego komputera. Domyślnie w lokalizacji, w której się znajdujesz w terminalu zostanie utworzony folder o nazwie repozytorium, które klonujesz i o to mi chodziło w tym określeniu.
Te pojęcie nie odnosi się stricte do Linuksa – git jest dostępny na prawie każdy system operacyjny jaki jest. Tak samo by to działało, gdybyś miał zainstalowane binaria gita na Windowsie bez WSL.
„Niestety, ja potrzebuje screen umożliwiające dotarcie do pliku, w którym mógłbym zmieniać dane dostępowe do serwerów pocztowych.”
Na końcu poradnika podałem przykład jak stworzyć plik z danymi dostępowymi do skrzynek pocztowych + w poleceniu do imapsync podaje się te dane. Spróbuj z tego skorzystać.
Tak, więc po uruchomieniu Ubuntu, należy wpisać „ls”, pojawi się nazwa folderu „imapsync”. Następnie piszemy „cd imapsync”. Później tworzymy plik .sh z danymi skrzynek, czyli uruchamiamy edytor tekstu poleceniem „nano ~”, wklejamy dane dostępowe do skrzynek, zapisujemy np pod nazwa test.sh, zamykamy, wpisujemy „bash test.sh” – takie podstawy, może komuś się przyda.
Problem i prośba o pomoc. Dlaczego nie skopiowało e-mail na nowy serwer? Połączenie z oba serwerami nastąpiło. Program Imapsync widzi ilość e-mail, folderów na jednym i drugim serwerze. Do synchronizacji użyłem polecenia:
./imapsync –host1 poczta.xxx.net.pl –user1 janek@xxx.net.pl –password1 TSTSS1# –ssl1 –host2 ww12.serwer.pl –user2 janek@xxx.net.pl –password2 TSTSS1# –automap –justfolders –dry
Poniżej zdjęcia: https://uploads.disquscdn.com/images/64644b70492c46b9addb72ce0ac7970fc9dd9a9006c810e33696b6b47e5d5190.png https://uploads.disquscdn.com/images/f5b804792e50ce3879402e5936ebd5e08e993bb4e9540fac18db3ac4b8b9b307.png https://uploads.disquscdn.com/images/d0af1dd8195333beac0109c82d8e4c38901f675c5e0537571fd7f00b5775e1b9.jpg https://uploads.disquscdn.com/images/3fd83a22a39b362be4d353dec0a22c7f3d32e3304fb80e69f30b2997e248d342.png
wrzuć pełny log, z tego nic nie wynika
Poniżej LOG (ze zmienionymi przed publikacją adresami e-mail, nazwami hostów).
Link z podobnym problemem: https://github.com/imapsync/imapsync/issues/56
Here is imapsync 1.977 on host Fujitsu, a linux system with 4.0/7.8 free GiB of RAM
with Perl 5.26.1 and Mail::IMAPClient 3.39
Transfer started at Wed Jan 6 08:39:38 2021
PID is 62 my PPID is 61
Log file is LOG_imapsync/2021_01_06_08_39_38_699_janusz.terlak@rosol.net.pl_janusz.terlak@rosol.net.pl.txt ( to change it, use –logfile path ; or use –nolog to turn off logging )
Load is 0.52 0.58 0.59 1/6 on 4 cores
Current directory is /home/supra/imapsync
Real user id is supra (uid 1000)
Effective user id is supra (euid 1000)
$RCSfile: imapsync,v $ $Revision: 1.977 $ $Date: 2019/12/23 20:18:02 $
Command line used, run by /usr/bin/perl:
./imapsync –host1 poczta7498.xxx.pl –user1 janusz.terlak@rosol.net.pl –password1 MASKED –ssl1 –host2 wt56.yyyy.pl –user2 janusz.terlak@rosol.net.pl –password2 MASKED –automap –justfolders –dry
Temp directory is /tmp ( to change it use –tmpdir dirpath )
kill -QUIT 62 # special behavior: call to sub catch_exit
kill -TERM 62 # special behavior: call to sub catch_exit
kill -INT 62 # special behavior: call to sub catch_reconnect
kill -HUP 62 # special behavior: call to sub catch_print
kill -USR1 62 # special behavior: call to sub toggle_sleep
File /tmp/imapsync.pid does not exist
PID file is /tmp/imapsync.pid ( to change it, use –pidfile filepath ; to avoid it use –pidfile „” )
Writing my PID 62 in /tmp/imapsync.pid
Writing also my logfile name in /tmp/imapsync.pid : LOG_imapsync/2021_01_06_08_39_38_699_janusz.terlak@rosol.net.pl_janusz.terlak@rosol.net.pl.txt
Modules version list:
Authen::NTLM 1.09
CGI 4.51
Compress::Zlib 2.074
Crypt::OpenSSL::RSA 0.28
Data::Uniqid 0.12
Digest::HMAC_MD5 1.01
Digest::HMAC_SHA1 1.03
Digest::MD5 2.55
Encode 2.88
Encode::IMAPUTF7 1.05
File::Copy::Recursive 0.40
File::Spec 3.67
Getopt::Long 2.49
HTML::Entities 3.69
IO::Socket 1.38
IO::Socket::INET 1.35
IO::Socket::INET6 2.72
IO::Socket::IP 0.38
IO::Socket::SSL 2.060
IO::Tee 0.65
JSON 2.97001
JSON::WebToken 0.10
LWP 6.31
MIME::Base64 3.15
Mail::IMAPClient 3.39
Net::Ping 2.55
Net::SSLeay 1.84
Term::ReadKey 2.37
Test::MockObject 1.20161202
Time::HiRes 1.9741
URI::Escape 3.31
Unicode::String 2.10
( use –no-modulesversion to turn off printing this Perl modules list )
Info: will resync flags for already transferred messages. Use –noresyncflags to not resync flags.
Host2: probing ssl on port 993 ( use –nosslcheck to avoid this ssl probe )
Host2: sslcheck detected open ssl port 993 so turning ssl on (use –nossl2 –notls2 to turn off SSL and TLS wizardry)
SSL debug mode level is –debugssl 1 (can be set from 0 meaning no debug to 4 meaning max debug)
Host1: SSL default mode is like –sslargs1 „SSL_verify_mode=0”, meaning for host1 SSL_VERIFY_NONE, ie, do not check the certificate server.
Host1: Use –sslargs1 SSL_verify_mode=1 to have SSL_VERIFY_PEER, ie, check the certificate server of host1
Host2: SSL default mode is like –sslargs2 „SSL_verify_mode=0”, meaning for host2 SSL_VERIFY_NONE, ie, do not check the certificate server.
Host2: Use –sslargs2 SSL_verify_mode=1 to have SSL_VERIFY_PEER, ie, check the certificate server of host2
Info: turned ON syncinternaldates, will set the internal dates (arrival dates) on host2 same as host1.
Host1: will try to use LOGIN authentication on host1
Host2: will try to use LOGIN authentication on host2
Host1: imap connection timeout is 120 seconds
Host2: imap connection timeout is 120 seconds
Host1: IMAP server [poczta7498.xxx.pl] port [993] user [janusz.terlak@rosol.net.pl]
Host2: IMAP server [wt56.yyyy.pl] port [993] user [janusz.terlak@rosol.net.pl]
Host1: connecting and login on host1 [poczta7498.xxx.pl] port [993] with user [janusz.terlak@rosol.net.pl]
Host1 IP address: 94.152.195.118
Host1 banner: * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN AUTH=CRAM-MD5 AUTH=DIGEST-MD5] Dovecot ready.
Host1 capability before authentication: IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN AUTH=CRAM-MD5 AUTH=DIGEST-MD5
Host1: poczta7498.xxx.pl says it has CAPABILITY for AUTHENTICATE LOGIN
Host1: success login on [poczta7498.xxx.pl] with user [janusz.terlak@rosol.net.pl] auth [LOGIN]
Host2: connecting and login on host2 [wt56.yyyy.pl] port [993] with user [janusz.terlak@rosol.net.pl]
Host2 IP address: 194.181.228.60
Host2 banner: * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
Host2 capability before authentication: IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=PLAIN AUTH=LOGIN
Host2: wt56.yyyy.plsays it has CAPABILITY for AUTHENTICATE LOGIN
Host2: success login on [wt56.yyyy.pl] with user [janusz.terlak@rosol.net.pl] auth [LOGIN]
Host1: state Authenticated
Host2: state Authenticated
Host1 capability once authenticated: IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE QUOTA
Host2 capability once authenticated: IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY STATUS=SIZE SAVEDATE NAMESPACE LITERAL+ NOTIFY SPECIAL-USE COMPRESS=DEFLATE QUOTA
Host1: found ID capability. Sending/receiving ID, presented in raw IMAP for now.
In order to avoid sending/receiving ID, use option –noid
Sending: 4 ID („name” „imapsync” „version” „1.977” „os” „linux” „vendor” „Gilles LAMIRAL” „support-url” „https://imapsync.lamiral.info/” „date” „23-Dec-2019 20:18:02 +0000” „side” „host1”)
Sent 181 bytes
Read: * ID („name” „Dovecot”)
4 OK ID completed (0.001 + 0.000 secs).
Host2: found ID capability. Sending/receiving ID, presented in raw IMAP for now.
In order to avoid sending/receiving ID, use option –noid
Sending: 4 ID („name” „imapsync” „version” „1.977” „os” „linux” „vendor” „Gilles LAMIRAL” „support-url” „https://imapsync.lamiral.info/” „date” „23-Dec-2019 20:18:02 +0000” „side” „host2”)
Sent 181 bytes
Read: * ID („name” „Dovecot”)
4 OK ID completed (0.001 + 0.000 secs).
Host2: found quota, presented in raw IMAP
Sending: 5 GETQUOTAROOT INBOX
Sent 22 bytes
Read: * QUOTAROOT INBOX „”
* QUOTA „” (STORAGE 79 256000)
5 OK Getquotaroot completed (0.001 + 0.000 secs).
Host2: Quota current storage is 80896 bytes. Limit is 262144000 bytes. So 0.03 % full
Host1: found 5 folders.
Host2: found 7 folders.
Host1: guessing separator from folder listing: [.]
Host1: separator given by NAMESPACE: [.]
Host2: guessing separator from folder listing: [.]
Host2: separator given by NAMESPACE: [.]
Host1: guessing prefix from folder listing: [INBOX.]
Host1: prefix given by NAMESPACE: [INBOX.]
Host2: guessing prefix from folder listing: [INBOX.]
Host2: prefix given by NAMESPACE: [INBOX.]
Host1: separator and prefix: [.][INBOX.]
Host2: separator and prefix: [.][INBOX.]
Including all folders found by default. Use –subscribed or –folder or –folderrec or –include to select specific folders. Use –exclude to unselect specific folders.
Host1: Checking wanted folders exist. Use –nocheckfoldersexist to avoid this check (shared of public namespace targeted).
Host1: Checking wanted folders are selectable. Use –nocheckselectable to avoid this check.
Turned on automapping folders ( use –noautomap to turn off automapping )
Host1: special INBOX.Drafts = Drafts
Host1: special INBOX.Spam = Junk
Host1: special INBOX.Sent = Sent
Host1: special INBOX.Trash = Trash
Host2: special INBOX.Archive = Archive
Host2: special INBOX.Sent = Sent
Host2: special INBOX.Drafts = Drafts
Host2: special INBOX.Trash = Trash
Host2: special INBOX.Junk = Junk
++++ Listing folders
All foldernames are presented between brackets like [X] where X is the foldername.
When a foldername contains non-ASCII characters it is presented in the form
[X] = [Y] where
X is the imap foldername you have to use in command line options and
Y is the utf8 output just printed for convenience, to recognize it.
Host1: folders list (first the raw imap format then the [X] = [Y]):
* LIST (HasChildren) „.” INBOX
* LIST (HasNoChildren Drafts) „.” INBOX.Drafts
* LIST (HasNoChildren Junk) „.” INBOX.Spam
* LIST (HasNoChildren Sent) „.” INBOX.Sent
* LIST (HasNoChildren Trash) „.” INBOX.Trash
15 OK List completed (0.001 + 0.000 secs).
[INBOX]
[INBOX.Drafts]
[INBOX.Sent]
[INBOX.Spam]
[INBOX.Trash]
Host2: folders list (first the raw imap format then the [X] = [Y]):
* LIST (HasChildren) „.” INBOX
* LIST (HasNoChildren UnMarked Archive) „.” INBOX.Archive
* LIST (HasNoChildren UnMarked) „.” INBOX.spam
* LIST (HasNoChildren UnMarked Sent) „.” INBOX.Sent
* LIST (HasNoChildren UnMarked Drafts) „.” INBOX.Drafts
* LIST (HasNoChildren UnMarked Trash) „.” INBOX.Trash
* LIST (HasNoChildren UnMarked Junk) „.” INBOX.Junk
11 OK List completed (0.001 + 0.000 secs).
[INBOX]
[INBOX.Archive]
[INBOX.Drafts]
[INBOX.Junk]
[INBOX.Sent]
[INBOX.Trash]
[INBOX.spam]
Folders in host2 not in host1:
[INBOX.spam]
[INBOX.Archive]
Folders mapping from –automap feature (use –f1f2 to override any mapping):
[INBOX.Drafts] -> [INBOX.Drafts]
[INBOX.Sent] -> [INBOX.Sent]
[INBOX.Trash] -> [INBOX.Trash]
[INBOX.Spam] -> [INBOX.Junk]
++++ Looping on each one of 5 folders to sync
Folder 1/5 [INBOX] -> [INBOX]
Host1: folder [INBOX] has 3 messages in total (mentioned by SELECT)
Host2: folder [INBOX] has 1 messages in total (mentioned by SELECT)
Host2: folder [INBOX] permanentflags:
Folder 2/5 [INBOX.Drafts] -> [INBOX.Drafts]
Host1: folder [INBOX.Drafts] has 0 messages in total (mentioned by SELECT)
Host2: folder [INBOX.Drafts] has 0 messages in total (mentioned by SELECT)
Host2: folder [INBOX.Drafts] permanentflags:
Folder 3/5 [INBOX.Sent] -> [INBOX.Sent]
Host1: folder [INBOX.Sent] has 0 messages in total (mentioned by SELECT)
Host2: folder [INBOX.Sent] has 1 messages in total (mentioned by SELECT)
Host2: folder [INBOX.Sent] permanentflags:
Folder 4/5 [INBOX.Spam] -> [INBOX.Junk]
Host1: folder [INBOX.Spam] has 0 messages in total (mentioned by SELECT)
Host2: folder [INBOX.Junk] has 0 messages in total (mentioned by SELECT)
Host2: folder [INBOX.Junk] permanentflags:
Folder 5/5 [INBOX.Trash] -> [INBOX.Trash]
Host1: folder [INBOX.Trash] has 0 messages in total (mentioned by SELECT)
Host2: folder [INBOX.Trash] has 0 messages in total (mentioned by SELECT)
Host2: folder [INBOX.Trash] permanentflags:
++++ End looping on each folder
Folders sizes after the synchronization.
You can remove this foldersizes listing by using „–nofoldersizesatend”
Host1 folder 1/5 [INBOX] Size: 301782 Messages: 3 Biggest: 211951
Host2 folder 1/5 [INBOX] Size: 79834 Messages: 1 Biggest: 79834
Host2-Host1 -221948 -2 -132117
Host1 folder 2/5 [INBOX.Drafts] Size: 0 Messages: 0 Biggest: 0
Host2 folder 2/5 [INBOX.Drafts] Size: 0 Messages: 0 Biggest: 0
Host2-Host1 0 0 0
Host1 folder 3/5 [INBOX.Sent] Size: 0 Messages: 0 Biggest: 0
Host2 folder 3/5 [INBOX.Sent] Size: 411 Messages: 1 Biggest: 411
Host2-Host1 411 1 411
Host1 folder 4/5 [INBOX.Spam] Size: 0 Messages: 0 Biggest: 0
Host2 folder 4/5 [INBOX.Junk] Size: 0 Messages: 0 Biggest: 0
Host2-Host1 0 0 0
Host1 folder 5/5 [INBOX.Trash] Size: 0 Messages: 0 Biggest: 0
Host2 folder 5/5 [INBOX.Trash] Size: 0 Messages: 0 Biggest: 0
Host2-Host1 0 0 0
Host1 Nb folders: 5 folders
Host2 Nb folders: 5 folders
Host1 Nb messages: 3 messages
Host2 Nb messages: 2 messages
Host1 Total size: 301782 bytes (294.709 KiB)
Host2 Total size: 80245 bytes (78.364 KiB)
Host1 Biggest message: 211951 bytes (206.983 KiB)
Host2 Biggest message: 79834 bytes (77.963 KiB)
Time spent on sizing: 1.2 seconds
++++ Statistics
Transfer started on : Wed Jan 6 08:39:38 2021
Transfer ended on : Wed Jan 6 08:39:54 2021
Transfer time : 16.0 sec
Folders synced : 5/5 synced
Messages transferred : 0 (could be 0 without dry mode)
Messages skipped : 0
Messages found duplicate on host1 : 0
Messages found duplicate on host2 : 0
Messages found crossduplicate on host2 : 0
Messages void (noheader) on host1 : 0
Messages void (noheader) on host2 : 0
Messages found in host1 not in host2 : 0 messages
Messages found in host2 not in host1 : 0 messages
Messages deleted on host1 : 0
Messages deleted on host2 : 0
Total bytes transferred : 0 (0.000 KiB)
Total bytes skipped : 0 (0.000 KiB)
Message rate : 0.0 messages/s
Average bandwidth rate : 0.0 KiB/s
Reconnections to host1 : 0
Reconnections to host2 : 0
Memory consumption at the end : 187.1 MiB (started with 171.2 MiB)
Load end is : 0.52 0.58 0.59 1/6 on 4 cores
Biggest message : 0 bytes (0.000 KiB)
Memory/biggest message ratio : NA
Detected 0 errors
Check if a new imapsync release is available by adding –releasecheck
Homepage: https://imapsync.lamiral.info/
Exiting with return value 0 (EX_OK: successful termination) 0/50 nb_errors/max_errors
Log file is LOG_imapsync/2021_01_06_08_39_38_699_janusz.terlak@rosol.net.pl_janusz.terlak@rosol.net.pl.txt ( to change it, use –logfile filepath ; or use –nolog to turn off logging )
supra@Fujitsu:~/imapsync$
wg logu w skrzynce źródłowej nie ma prawie w ogóle maili, czy ona ma jakieś wiadomości?
Na potrzeby testów i nauki obsługi Imapsync, utworzyłem adres e-mail (tymczasowy). Są 2 – 3 wiadomości. Nie chcę się uczyć na produkcyjnych skrzynkach.
Na host1 można wysłać wiadomość i ją odebrać, bo domena własna jest podpięta i poprawnie skonfigurowana. Na host2 nie uda się wysłać i odebrać, bo czeka na przełączenie domeny, po migracji poczty.
w takiej sytuacji szukałbym błędów specyficznych do serwer(ów) pocztowych, które wykorzystujesz tutaj:
https://imapsync.lamiral.info/FAQ.d/
Sprawdziłem w Outlook czy metodą PRZESUŃ Z JEDNEJ SKRZYNKI DO DRUGIEJ uda się zsynchronizować wiadomości. Udało się. W Outlook opcją która nie występuje w pleceniach Imapserver jest „serwer wychodzący (smtp) wymaga uwierzytelnienia – użyj tych samych ustawień, co mój serwer poczty przychodzącej”, ale to zapewne nie ma wpływu. W każdym bądź razie pisze o tym, bo może w poleceniu którego używam brakuje jakiegoś parametru?
ciężko mi powiedzieć, ale ogólnie listę wszystkich parametrów do imapsynca można znaleźć tutaj:
https://linux.die.net/man/1/imapsync
Usunałem parametry wpisane na końcu, czyli –automap –justfolders –dry i poczta z host1 skopiowała się na host2
Pozdrawiam.
Cieszę się, że mogłem pomóc :>