====== 將 Mail Server - IMAP 建立的中文目錄編碼轉回作法 ======
透過 [[https://imapsync.lamiral.info/|imapsync]] 移轉 Mail Server 過程, 發現一些使用中文所建立的目錄無法成功移轉, 又不好比對出是那些目錄, 所以找了一下可以如何將編碼轉回的方式.
* 在 imapsync 執行後的 LOG_imapsync 目錄內看到記錄檔最後有出現 Err Exp.
:
:
Homepage: http://imapsync.lamiral.info/
++++ Listing 2 errors encountered during the sync ( avoid this listing with --noerrorsdump ).
Err 1/2: Could not create folder [from ABC/&ZbBbomI2--DATA/INDIA/JonathanTest.] from [from ABC/&ZbBbomI2--DATA/INDIA/JonathanTest.]: 38252 NO [CANNOT] Character not allowed in mailbox name: '.' (0.001 + 0.000 secs).
Err 2/2: Could not create folder [from ABC/&ZbBbomI2--DATA/Vietnam/TrysoftTest] from [from ABC/&ZbBbomI2--DATA/Vietnam/TrysoftTest]: 38949 NO [CANNOT] Character not allowed in mailbox name: '.' (0.001 + 0.000 secs).
Exiting with return value 111
Log file is LOG_imapsync/2018_08_26_16_21_49_try.txt ( to change it, use --logfile filepath ; or use --nolog to turn off logging )
* 出現了兩個目錄異常
- [from ABC/&ZbBbomI2--DATA/INDIA/JonathanTest.]
- [from ABC/&ZbBbomI2--DATA/Vietnam/TrysoftTest]
===== CentOS 6 安裝 perl Unicode::IMAPUtf7 套件 =====
*
yum install https://www.rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/perl-Unicode-IMAPUtf7-2.00-1.el6.rf.noarch.rpm
===== 簡單寫個轉碼 perl 程式 =====
*
#!/usr/bin/perl
use Unicode::IMAPUtf7;
my $IMAPUtf7 = Unicode::IMAPUtf7->new();
$encode = '[from ABC/&ZbBbomI2--DATA/INDIA/JonathanTest.] [from ABC/&ZbBbomI2--DATA/Vietnam/TrysoftTest]';
$decode = $IMAPUtf7->decode($encode);
print("[$decode]\n");
root@ct-centos6 ~]# perl test.pl
[[from ABC/新客戶-DATA/INDIA/JonathanTest.] [from ABC/新客戶-DATA/Vietnam/TrysoftTest]]
[root@ct-centos6 ~]#
===== 參考網址 =====
* http://tyruan.blogspot.com/2013/11/outlook-imap.html
* https://www.rpmfind.net/linux/rpm2html/search.php?query=perl(Unicode%3A%3AIMAPUtf7)
如果對 perl 語法想快速了解, 可以參考以下網址 ((來自 Marc Wilson @PCWDLD.com 2021/09/07 的建議))
* https://www.pcwdld.com/perl-cheat-sheet
{{tag>mail imapsync}}