Converting mbox to maildir

mbox and maildir both are popularly used techniques to store mails. The simple way to understand the difference is, mbox uses a single directory to store all mails while maildir would utilize a directory structure to store mails. Most of the cases, advance mail receiving techniques IMAP over POP3 uses these sort of folder based concept to provide enhancement in mail organizing.

If you are having a POP3 account using mbox, you can use an open source tool called mb2md to convert it to maildir.

Full reference and how to use the tool is available here:
http://batleth.sapienti-sat.org/projects/mb2md/

How to convert mbox to maildir using mb2md?

First download the mb2md script from the developer

$ wget http://batleth.sapienti-sat.org/projects/mb2md/mb2md-3.20.pl.gz
$ gzip -d mb2md-3.20.pl.gz
$ chmod 755 mb2md-3.20.pl

Now, converting is simple. Use as following:

$ mb2md-3.20.pl -s /locationofmbox -R -d /destinationofmaildir

-s defines the source of the mbox, the location would depend on the type of environment you are using.
-R defines recursively do for all subdirectories
-d defines the destination of maildirectory inbox.

How to convert mbox to maildir in a directadmin instance manually?

For Example, if you are using Directadmin control panel, the mbox spool is located under /var/spool/virtual/domain.com/user. You would want to run something like this to convert the mbox into maildir in a directadmin control panel:

$ mb2md-3.20.pl -s /var/spool/virtual/domain.com/user -R -d /home/username/imap/domain.com/user/Maildir
$ chown -Rf username:mail /home/username/imap/domain.com/user/Maildir

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.