Difference between revisions of "Converting Mbox mailboxes to Maildir format"
(Created page with "== Overview == '''Maildir''' is a structure for directories of incoming mail messages that solves the reliability problems that plague '''mbox''' files. A directory in maildir...") |
m (→Download) |
||
(18 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
== The mb2md conversion script == | == The mb2md conversion script == | ||
+ | |||
+ | For an existing user who has mail messages in mbox format, the '''mb2md''' script is useful for converting the messages to maildir format. | ||
+ | |||
+ | === Download === | ||
+ | |||
+ | Download from http://www.akadia.com. | ||
+ | Version: [http://www.akadia.com/download/documents/mb2md-3.10.pl.gz mb2md-3.10] | ||
+ | (requires [http://www.akadia.com/download/documents/TimeDate-1.16.tar.gz TimeDate]!) | ||
+ | |||
+ | Download from mirror at https://petech.com. | ||
+ | Version: [https://download.petech.com/linux/mb2md-3.10.pl.gz mb2md-3.10] | ||
+ | (requires [https://download.petech.com/linux/TimeDate-1.16.tar.gz TimeDate]!) | ||
+ | |||
+ | === Installation === | ||
+ | |||
+ | Extract the mb2md script and copy it to the file '''mb2md''' somewhere in your path. Set the mb2md file permissions '''+x'''. | ||
+ | |||
+ | To install the TimeDate perl library, extract the files from the archive to a temporary location. Change the current directory to the extracted folder and run the following commands: | ||
+ | perl Makefile.PL | ||
+ | make | ||
+ | make test | ||
+ | make install | ||
+ | |||
+ | === Example Usage === | ||
+ | |||
+ | For detailed usage and examples, see the comments at the beginning of the mb2md script. For usage summary type <code>mb2md -h</code>. | ||
+ | |||
+ | We have a bunch of directories of Mbox mailboxes located at: <code>/home/blah/oldmail/</code>. | ||
+ | We also have the mailspool Inbox at: <code>/var/spool/mail/blah</code>. | ||
+ | |||
+ | To convert these, as user blah, we give the first command: | ||
+ | mb2md -m | ||
+ | The main Maildir directory will be created if it does not exist. | ||
+ | (This is true of any argument options, not just "-m".) | ||
+ | /home/blah/Maildir/ | ||
+ | It has the following subdirectories: | ||
+ | /home/blah/Maildir/tmp/ | ||
+ | /home/blah/Maildir/new/ | ||
+ | /home/blah/Maildir/cur/ | ||
+ | Then /var/spool/blah file is read, split into individual files and written into <code>/home/blah/Maildir/new/</code>. | ||
+ | |||
+ | Now we give the second command: | ||
+ | mb2md -s oldmail -R | ||
+ | This reads recursively all Mbox mailboxes and writes folders and files in Maildir format into <code>/home/blah/Maildir</code>. | ||
+ | |||
+ | Reference: [http://www.akadia.com/services/converting_mbox_mdir.html Converting Mbox mailboxes to Maildir format] | ||
== Configuring mail servers for Maildir delivery == | == Configuring mail servers for Maildir delivery == | ||
− | === Configuring procmail === | + | === Configuring procmail for Maildir === |
+ | Create the configuration file <code>/etc/procmailrc</code> for global implementation or you may create per user basis file in <code>$HOME/.procmailrc</code>. | ||
+ | |||
+ | Add the following contents to it: | ||
+ | PATH=/usr/local/bin:/usr/bin:/bin | ||
+ | MAILDIR=$HOME/Maildir | ||
+ | DEFAULT=$MAILDIR/new #completely optional | ||
+ | # LOGFILE=$MAILDIR/log #recommended | ||
+ | LOGFILE=/var/log/procmail #or this | ||
+ | |||
+ | Reference: [http://www.mylinuxtips.info/sendmail-with-maildir-format-delivery/linuxtipstutorials/16/ Sendmail with MAILDIR format delivery] | ||
+ | |||
+ | === Configuring sendmail to use procmail === | ||
+ | |||
+ | To setup sendmail to handle mail delivery by procmail, in <code>/etc/mail/sendmail.mc</code> file edit the following line:<br> | ||
+ | Existing settings: | ||
+ | dnl # FEATURE(local_procmail, `', `procmail -t -Y -a $h -d $u')dnl | ||
+ | Modified Settings: | ||
+ | FEATURE(local_procmail)dnl | ||
+ | MAILER(procmail)dnl | ||
+ | |||
+ | Make and restart sendmail. | ||
+ | |||
+ | Reference: [http://www.mylinuxtips.info/sendmail-with-maildir-format-delivery/linuxtipstutorials/16/ Sendmail with MAILDIR format delivery] | ||
+ | |||
+ | === Configuring postfix to use procmail === | ||
+ | |||
+ | Edit the configuration file <code>/etc/postfix/main.cf</code> to contain the following line: | ||
+ | mailbox_command = /usr/bin/procmail -a "$EXTENSION" | ||
+ | |||
+ | Restart postfix. | ||
+ | |||
+ | === Configuring dovecot for Maildir === | ||
− | = | + | Edit the configuration file <code>/etc/dovecot/conf.d/10-mail.conf</code> to contain the following line: |
+ | mail_location = maildir:~/Maildir | ||
− | + | Restart dovecot. | |
− | + | [[Category:Linux]] | |
+ | [[Category:Internet]] |
Latest revision as of 10:08, 8 June 2019
Overview
Maildir is a structure for directories of incoming mail messages that solves the reliability problems that plague mbox files. A directory in maildir format has three subdirectories, all on the same filesystem: tmp, new, and cur.
Each file in new is a newly delivered mail message. Files in cur are just like files in new. The big difference is that files in cur are no longer new mail: they have been seen by the user's mail-reading program. The tmp directory is used to ensure reliable delivery. For a new user who does not have existing mail messages in mbox format, all that is required is to create the ~/Maildir directory and its tmp, new, and cur subdirectories all owned by the user.
The mb2md conversion script
For an existing user who has mail messages in mbox format, the mb2md script is useful for converting the messages to maildir format.
Download
Download from http://www.akadia.com. Version: mb2md-3.10 (requires TimeDate!)
Download from mirror at https://petech.com. Version: mb2md-3.10 (requires TimeDate!)
Installation
Extract the mb2md script and copy it to the file mb2md somewhere in your path. Set the mb2md file permissions +x.
To install the TimeDate perl library, extract the files from the archive to a temporary location. Change the current directory to the extracted folder and run the following commands:
perl Makefile.PL make make test make install
Example Usage
For detailed usage and examples, see the comments at the beginning of the mb2md script. For usage summary type mb2md -h
.
We have a bunch of directories of Mbox mailboxes located at: /home/blah/oldmail/
.
We also have the mailspool Inbox at: /var/spool/mail/blah
.
To convert these, as user blah, we give the first command:
mb2md -m
The main Maildir directory will be created if it does not exist. (This is true of any argument options, not just "-m".)
/home/blah/Maildir/
It has the following subdirectories:
/home/blah/Maildir/tmp/ /home/blah/Maildir/new/ /home/blah/Maildir/cur/
Then /var/spool/blah file is read, split into individual files and written into /home/blah/Maildir/new/
.
Now we give the second command:
mb2md -s oldmail -R
This reads recursively all Mbox mailboxes and writes folders and files in Maildir format into /home/blah/Maildir
.
Reference: Converting Mbox mailboxes to Maildir format
Configuring mail servers for Maildir delivery
Configuring procmail for Maildir
Create the configuration file /etc/procmailrc
for global implementation or you may create per user basis file in $HOME/.procmailrc
.
Add the following contents to it:
PATH=/usr/local/bin:/usr/bin:/bin MAILDIR=$HOME/Maildir DEFAULT=$MAILDIR/new #completely optional # LOGFILE=$MAILDIR/log #recommended LOGFILE=/var/log/procmail #or this
Reference: Sendmail with MAILDIR format delivery
Configuring sendmail to use procmail
To setup sendmail to handle mail delivery by procmail, in /etc/mail/sendmail.mc
file edit the following line:
Existing settings:
dnl # FEATURE(local_procmail, `', `procmail -t -Y -a $h -d $u')dnl
Modified Settings:
FEATURE(local_procmail)dnl MAILER(procmail)dnl
Make and restart sendmail.
Reference: Sendmail with MAILDIR format delivery
Configuring postfix to use procmail
Edit the configuration file /etc/postfix/main.cf
to contain the following line:
mailbox_command = /usr/bin/procmail -a "$EXTENSION"
Restart postfix.
Configuring dovecot for Maildir
Edit the configuration file /etc/dovecot/conf.d/10-mail.conf
to contain the following line:
mail_location = maildir:~/Maildir
Restart dovecot.