Results 1 to 7 of 7

Thread: Maildir to Zimbra

  1. #1
    drwho18 is offline Senior Member
    Join Date
    May 2007
    Posts
    63
    Rep Power
    8

    Default Maildir to Zimbra

    This is a modification of the Maildir import script on the Wiki. It copies the messages to the correct folder on Zimbra, it also will copy folder names with spaces in them, and I've joined the cur/new folder stuff into one loop, rather then two. I've also exempted creation of certain mailboxes that exist within zimbra by default to avoid zmmailbox error delay's.

    I'm not a proficient bash coder, so if there is major issues with it please let me know. I've migrated about 300GB with it, without issue.

    One thing that it doesn't do is set the flags, I haven't quite figured out how to do that with zmmailbox/zimbra yet. I know I can do it with imapsync, but I'd rather do it from the same script.


    #!/bin/bash

    #
    # Maildir to Zimbra import
    # Drop in your user root and run as superuser.
    #

    domain="domain.com" # change to your domain!

    for user in `ls -d1 */|sed s/\\\///`
    do
    echo
    echo "User $user"
    echo
    #
    #
    find $user -maxdepth 10 -type d -name cur | while read line;
    do
    folder=`echo ${line}|cut -f3 -d"/"|sed s/\\\.//`
    line2=`echo ${line/%cur/new}`
    echo "FOLDER $folder"
    if [ "$folder" = "cur" ]
    then
    /opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage Inbox $PWD/$user/.maildir/cur
    /opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage Inbox $PWD/$user/.maildir/new
    else
    if [ "$folder" != "Sent" ] && [ "$folder" != "Drafts" ] && [ "$folder" != "Junk" ] && [ "$folder" != "Trash" ]
    then
    /opt/zimbra/bin/zmmailbox -z -m $user@$domain createFolder "/$folder"
    fi
    /opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage "/$folder" "${PWD}/${line}"
    /opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage "/$folder" "${PWD}/${line2}"
    fi
    done

    done
    Last edited by drwho18; 11-30-2008 at 05:35 AM.

  2. #2
    phoenix is offline Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,566
    Rep Power
    57

    Default

    Thanks for your work on this. Would you mind adding this to the wiki article (so it's all kept in one place)? You'll need to create an account on the wiki to modify the pages.
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  3. #3
    drwho18 is offline Senior Member
    Join Date
    May 2007
    Posts
    63
    Rep Power
    8

    Default

    Well, I'm not entirely finished, that's why I was looking for feedback and further optimizations. I also trying to figure out how to handle the message flags within the same script, with minimal configuration on the part of the user.

  4. #4
    r1ch97rd is offline Starter Member
    Join Date
    Jun 2009
    Posts
    2
    Rep Power
    6

    Default

    Thanks for the script. It works except that the unread flag is lost on messages after importing.
    Is there any way to keep message flags?

  5. #5
    diadem is offline Starter Member
    Join Date
    Apr 2010
    Posts
    1
    Rep Power
    5

    Default Plesk Maildir to Zimbra

    Thanks for the script. I have modified the script to restore mails from Plesk (Qmail) server to zimbra server.

    HTML Code:
    #!/bin/bash
    #
    # Maildir to Zimbra import
    # Drop in your user root and run as superuser.
    #
    
    domain="domain.com" # change to your domain!
    
    for user in `ls -d1 */|sed s/\\\///`
    do
    echo
    echo "User $user"
    echo
    #
    #
    find $user -maxdepth 10 -type d -name cur | while read line;
    do
    folder=`echo ${line}|cut -f3 -d"/"|sed s/\\\.//`
    line2=`echo ${line/%cur/new}`
    echo "FOLDER $folder"
    if [ "$folder" = "cur" ]
    then
    /opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage Inbox $PWD/$user/Maildir/cur
    /opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage Inbox $PWD/$user/Maildir/new
    else
    if [ "$folder" != "Sent" ] && [ "$folder" != "Drafts" ] && [ "$folder" != "Junk" ] && [ "$folder" != "Trash" ]
    then
    /opt/zimbra/bin/zmmailbox -z -m $user@$domain createFolder "/$folder"
    fi
    /opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage "/$folder" "${PWD}/${line}"
    /opt/zimbra/bin/zmmailbox -z -m $user@$domain addMessage "/$folder" "${PWD}/${line2}"
    fi
    done
    
    done
    I have tested (Zimbra Release 6.0.6 in Fedora 7 box) and It's working fine for me.
    Last edited by diadem; 05-11-2010 at 03:50 AM.

  6. #6
    zhucekankan is offline Junior Member
    Join Date
    May 2010
    Posts
    5
    Rep Power
    5

    Default

    Great, I finish the mail moving use this scripts, but I remove the "Maildir/" from the scripts before run it.

    Thanks

  7. #7
    zhucekankan is offline Junior Member
    Join Date
    May 2010
    Posts
    5
    Rep Power
    5

    Question

    Oops.
    Some email cannot be imported, get a RFC822 mailformat error:
    ERROR: zclient.CLIENT_ERROR (***skipped email file name*** does not contain a valid RFC 822 message)

    Wonder whether anyone have suggestion on this issue?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. slapd message error
    By smoke in forum Administrators
    Replies: 7
    Last Post: 04-27-2008, 03:23 PM
  2. admin consol blank after 5.0.3 upgarde
    By maumar in forum Administrators
    Replies: 6
    Last Post: 03-21-2008, 05:16 AM
  3. Replies: 12
    Last Post: 02-25-2008, 07:28 PM
  4. Zimbra shutdowns every n hours.
    By Andrewb in forum Administrators
    Replies: 13
    Last Post: 08-14-2007, 08:55 AM
  5. Post instsallation problems
    By Assaf in forum Installation
    Replies: 14
    Last Post: 01-29-2007, 11:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •