在linux下的邮件一般有两种形式,一种是mbox形式,一种是maildir形式,mbox是以一个txt文件的形式存储用户的邮件,而maildir是以一个目录的形式,目录下又分成tmp,cur,new三个目录,用户写邮件、发送邮件、接收邮件将使用不同的目录。关于mbox与maildir的区别可以参考以下文章:
http://www.linuxmail.info/mbox-maildir-mail-storage-formats/
postfix、dovecot、courier支持两种方式,而openwebmail只运行mbox方式。postfix默认的是mbox方式,要想修改为maildir,可以按以下步骤:
1、修改/etc/courier/imapd,最后一行修改为MAILDIRPATH=Maildir/
2、修改/etc/postfix/main.cf,找到以下行
mailbox_command = procmail -a "$EXTENSION"
修改为
mailbox_command = procmail -a "$EXTENSION" DEFAULT=$HOME/Maildir/ MAILDIR=$HOME/Maildir (为一行)
3、重启courier、postfix服务
service courier restart 或者 /etc/init,d/courier-imap restart
service postfix restart 或者 /etc/init.d/postfix restart
ps: maildir方式默认会在收到第一封邮件时自动在/home/USER/下新建Maildir目录,及目录下的cur, new, tmp目录。 如果想手动创建,可以用以下方式
# cd /home/User
# maildirmake Maildir
# chown -R User:User Maildir
# chmod -R 750 Maildir
步骤2可参考以下:
If you are using the built in delivery agent you should put this into /etc/postfix/main.cf:
home_mailbox = Maildir/
If you are using procmail as your delivery agent, you should put this into /etc/postfix/main.cf (it is all one line):
mailbox_command = /usr/bin/procmail -a "$EXTENSION" DEFAULT=$HOME/Maildir/ MAILDIR=$HOME/Maildir
When the mailbox location does not end in /, the message is delivered in UNIX mailbox format. This format stores multiple messages in one textfile.
When the mailbox location ends in /, the message is delivered in qmail maildir format. This format stores one message per file
MTA: postfix
修改 main.cf
home_mailbox = Maildir/
MDA: procmail
修改 /etc/procmailrc
MAILDIR=$HOME/Maildir
DEFAULT=$HOME/Maildir/ (後面要加 / )
POP3: dovecot
修改 dovecot.conf
default_mail_env = maildir:/home/%u/Maildir
MUA: mutt
參考 rafan's blog » 從 mbox 到 maildir
把mbox邮箱格式转化为maildir格式可以使用一个工具mb2mb
http://batleth.sapienti-sat.org/projects/mb2md/
参考资料:
http://www.linuxmail.info/mbox-maildir-mail-storage-formats/
http://www.postfix.org/faq.html#maildir
http://www.pocock.com.au/portal/portal/pocock/wiki/Wiki;jsessionid=26A27AEC25C61395DBA5CB2408012749?action=e&windowstate=normal&page=ConvertMboxToMailbox&mode=view&language=EN