tech:mail_imap_encode

將 Mail Server - IMAP 建立的中文目錄編碼轉回作法

透過 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 )
  • 出現了兩個目錄異常
    1. [from ABC/&ZbBbomI2–DATA/INDIA/JonathanTest.]
    2. [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 程式

  • test.pl
    #!/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");

    [email protected] ~]# perl test.pl
    [[from ABC/新客戶-DATA/INDIA/JonathanTest.] [from ABC/新客戶-DATA/Vietnam/TrysoftTest]]
    [[email protected] ~]#
    

參考網址

tech/mail_imap_encode.txt · 上一次變更: 2018/09/03 16:27 由 Jonathan Tsai