Results 1 to 17 of 17

Thread: Manually convert to Maildir

  1. #1
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    388

    Manually convert to Maildir

    Hi,

    I have converted to dovecot and one account is deleted all the email while converting.

    I have daily backup on my server and it only have mbox format. How do i manually convert the mbox to Maildir for the particular users

  2. #2
    Join Date
    Aug 2003
    Location
    Schenectady, NY
    Posts
    1,178
    I dont KNOW for certain, but this line will upgrade all users:

    echo "action=convert&value=todovecot" >> /usr/local/directadmin/data/task.queue

    it MIGHT be possible to insert a user= to that line - John would have to comment on that however... I'm NOT playing with it at this point - got enough problems with this version of dovecot
    Joseph Mack http://www.hostpc.com Since November 1998
    DirectAdmin Hosting and Dedicated Servers Since August 2003

  3. #3
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    388
    John give a simple script to convert individual users.

    Work like a charm

  4. #4
    Join Date
    Jul 2003
    Posts
    474
    why is this script not posted here??

  5. #5
    Taken from http://www.qmail.org/mbox2maildir
    and modified very lightly:
    PHP Code:
    #!/usr/bin/perl
    #
    # mbox2maildir: coverts mbox file to maildir directory - the reverse of
    # maildir2mbox from the qmail distribution.
    #
    # Usage: mbox2maildir uses the same environment variables as maildir2mbox:
    # MAILDIR is the name of your maildir directory; MAIL is the name of your
    # mbox file; MAILTMP is ignored.
    # WARNING: there is no locking; don't run more than one of these!  you
    # have been warned.
    #
    # based on convert-and-create by Russell Nelson <nelson@qmail.org>
    # kludged into this by Ivan Kohler <ivan@voicenet.com> 97-sep-17
     
    require 'stat.pl';
     
    local $SIG{HUP} = 'IGNORE';
    local $SIG{INT} = 'IGNORE';
    local $SIG{QUIT} = 'IGNORE'
    local $SIG{TERM} = 'IGNORE';
    local $SIG{TSTP} = 'IGNORE';
     
    (
    $name$passwd$uid$gid$quota$comment$gcos$dir$shell) =
      
    getpwuid($<);
     
    die 
    "fatal: home dir $dir doesn't exist\n" unless -e $dir;
    &
    Stat($dir);
    die 
    "fatal: $name is $uid, but $dir is owned by $st_uid\n" if $uid != $st_uid;
     
    chdir($dir) or die "fatal: unable to chdir to $dir\n";
    $spoolname "$ENV{MAILDIR}";
    -
    d $spoolname or mkdir $spoolname,0770
      
    or die("fatal: $spoolname doesn't exist and can't be created.\n");
     
    chdir($spoolname) or die("fatal: unable to chdir to $spoolname.\n");
    -
    "tmp" or mkdir("tmp",0770) or die("fatal: unable to make tmp/ subdir\n");
    -
    "new" or mkdir("new",0770) or die("fatal: unable to make new/ subdir\n");
    -
    "cur" or mkdir("cur",0770) or die("fatal: unable to make cur/ subdir\n");
     
    open(SPOOL"<$ENV{MAIL}")
      or die 
    "Unable to open $ENV{$MAIL}\n";
    $i time;
    while(<
    SPOOL>) {
      if (/^
    From /) {
        
    $fn sprintf("new/%d.$$.mbox"$i);
        
    open(OUT">$fn") or die("fatal: unable to create new message");
        
    $i++;
        
    next;
      }
      
    s/^>From /From /;
      print 
    OUT or die("fatal: unable to write to new message");
    }
    close(SPOOL);
    close(OUT); 
    Usage:
    Code:
    [server]# MAIL=/var/spool/virtual/domain.com/user MAILDIR=/home/username/imap/domain.com/user/Maildir ./mbox2maildir
    Just make sure that the directories are chmod 770 and chown username:mail when it's done.

    John

  6. #6
    Join Date
    Oct 2003
    Location
    Switzerland
    Posts
    2,097
    This is the script that doesn't understand subfolders, changes all the dates and marks all the emails as unread, right?
    Olivier
    interfaCentre - We design custom hosting solutions

    Custom apps, scripts and configurations for easy and secure access to all hosting services
    Full Personal Information Management suite with mobile synchronisation
    PHP, Ruby, Node.js and Python hosting with 1-click app install

  7. #7
    Join Date
    Aug 2004
    Posts
    82
    btw if you want to set the dates to "hopefully" the right thing then you can use touch -t YYYYMMDDHHMM.SS filename

    you should be able to get the date out of the email from the Delivery-date header

    also if you want the files to be marked as unread then change the sprintf command to write to cur/ instead of new/ I think

  8. #8
    Join Date
    Oct 2003
    Location
    Switzerland
    Posts
    2,097
    The default conversion script does a very poor job, at least on FreeBSD.

    I'd recommend using mb2md:
    http://batleth.sapienti-sat.org/projects/mb2md

    I used it manually on some accounts with lots of imap folders and it worked well.
    Olivier
    interfaCentre - We design custom hosting solutions

    Custom apps, scripts and configurations for easy and secure access to all hosting services
    Full Personal Information Management suite with mobile synchronisation
    PHP, Ruby, Node.js and Python hosting with 1-click app install

  9. #9
    Join Date
    Jun 2003
    Location
    California
    Posts
    26,123
    Does mb2md manage to find and convert subfolders?

    Jeff
    +1 951 643-5345
    Third-Party DirectAdmin administration and support
    Dedicated Servers, Dedicated Reseller Accounts
    NoBaloney Internet Services div. Qnito Incorporated
    848 North Rainbow Blvd., Suite #3789
    Las Vegas, NV 89107-1103

  10. #10
    Join Date
    Oct 2003
    Location
    Switzerland
    Posts
    2,097
    Yes indeed.

    I used something like that:
    Code:
    mb2md -s /home/username/imap/domain/user/mail -R -d /home/username/imap/domain/user/Maildir
    There are shorter ways if you manage to run the script as the user (username).

    -s is the source
    -d is the destination
    -R tells it to do it recursively

    Dates are kept and emails are correctly put in "cur", so no more unread emails. Also the annoying "DO NOT DELETE" message is automatically removed.
    Olivier
    interfaCentre - We design custom hosting solutions

    Custom apps, scripts and configurations for easy and secure access to all hosting services
    Full Personal Information Management suite with mobile synchronisation
    PHP, Ruby, Node.js and Python hosting with 1-click app install

  11. #11
    Join Date
    Apr 2004
    Posts
    49
    I have Redhat 9, Redhat ES3 and Centos 4 and this worked well on all of them.

    I created the mb2md.pl file as per the instructions above and copied it to a new folder called mb2mb in my root folder so I could use it as shown below.
    remember to chmod it to 777 so you can execute it.

    This works for the virtual email accounts.It Works well.
    Code:
    cd /root/mb2mb
    ./mb2md.pl -s /var/spool/virtual/yourdomain.com/emailusername -R -d /home/username/imap/yourdomain.com/emailusername/Maildir
    cd /home/username/imap/yourdomain.com/emailusername/Maildir/cur
    chown username:mail *
    chmod 660 *
    this is for the site's root email account
    Code:
    cd /root/mb2md
    ./mb2md.pl -s /var/spool/mail/username -R -d /home/username/Maildir/
    cd /home/username/Maildir/cur
    chown username.mail *
    chmod 660 *
    Last edited by gerrybakker; 03-11-2006 at 10:14 AM.

  12. #12
    Join Date
    Feb 2005
    Location
    Finland
    Posts
    25

    Simple way to convert all IMAP folders (mbox) on server to Maildir

    Simple way to convert all at once IMAP folders (mbox) on server to Maildir

    Code:
    #!/bin/sh
    
    for u in `ls /usr/local/directadmin/data/users`; do
    {
        for d in `cat /usr/local/directadmin/data/users/$u/domains.list`; do
        {
            for e in `cat /etc/virtual/$d/passwd`; do
            {
                for r in `echo $e | cut -d: -f1`; do
                {
                mb2md -s /home/$u/imap/$d/$r/mail/mail -R -d /home/$u/imap/$d/$r/Maildir
                }
                done;
            }
            done;
        }
        done;
    }
    done;
    and for all main system accounts

    Code:
    #!/bin/sh
    
    for u in `ls /usr/local/directadmin/data/users`; do
    {
    mb2md -s /home/$u/mail/mail -R -d /home/$u/Maildir
    }
    done;
    This works if IMAP folders placed in
    /home/username/imap/domain.com/email_user/mail/mail (as for Horde on our
    servers). You can change path as you want
    Last edited by diradmin; 03-19-2006 at 09:28 AM.

  13. #13
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    49

    No dovecot - Yes MAILDIR !

    Hi All,

    Is it possible to convert some users to maildir while not yet using Dovecot ?

    Cheers,

    Vingertop
    Cheers,

    Vingertop

  14. #14
    Join Date
    Apr 2004
    Posts
    49
    YOU can't have it both ways - you need to convert all users to maildir at the same time which is what will happen if you use Dovecot.
    I did the move to Dovecot last January and never regretted the move. Things are much faster and easier to manage.

  15. #15
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    49
    OK i believe in the conversion, but i put some custom paths in my mailflow, (i had to change var/mail and var/spool/virtual) , that`s actually what is still holding me back.

    Can anyone assure that the paths to be used during conversion are paths read from the various directadmin.conf & exim.conf files ?
    Cheers,

    Vingertop

  16. #16
    Join Date
    Sep 2005
    Posts
    32
    Quote Originally Posted by diradmin View Post
    Simple way to convert all at once IMAP folders (mbox) on server to Maildir

    Code:
    #!/bin/sh
    ...
    mb2md ...
    ...
    Is this script nowadays also used for the 'todovecot'-conversion which is executed by the task.queue? Or is Directadmin still using the old way of converting mbox to maildirs? (which seemed to make some mistakes with time and status)

  17. #17
    Join Date
    Oct 2003
    Location
    Scottsdale, AZ
    Posts
    1,148
    This is what I used for those customers that actually used IMAP on my server. I made a few modifications to the original, so that the time stamps weren't changed and it maintained read/unread status. If it can't figure out the sent date/time it will default to current time. This worked fine for me.

    Download the text file rename to perfect_maildir.pl and to use
    perfect_maildir.pl /path/to/Maildir < mbox

    This would need to be used with a script, to process folders, but it does the mbox conversion better than most other utilities I tried.
    Attached Files Attached Files

Similar Threads

  1. Mailbox instead maildir why?
    By mjokiel in forum E-Mail
    Replies: 3
    Last Post: 07-11-2010, 12:10 PM
  2. Maildir
    By floyd in forum E-Mail
    Replies: 1
    Last Post: 05-31-2010, 11:24 AM
  3. Maildir instead of Mailbox
    By VinceSTM in forum E-Mail
    Replies: 5
    Last Post: 10-31-2006, 04:33 AM
  4. Convert maildir to mbox
    By mattbates in forum E-Mail
    Replies: 9
    Last Post: 04-18-2005, 12:10 PM
  5. maildir functionality
    By serenityhosting in forum E-Mail
    Replies: 1
    Last Post: 10-30-2004, 10:59 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
  •