2013-06-05

mbox轉maildir


 1. 下載 mb2md 3.2
[root@server tmp]# wget http://batleth.sapienti-sat.org/projects/mb2md/mb2md-3.20.pl.gz

2. 解壓縮

[root@server tmp]# gzip -d mb2md-3.20.pl.gz

# 用法說明 mb2md -s /var/spool/mail/user_mailbox -d /var/spool/mail/user_maildir
※ 注意: mb2md 需用完整路徑






3. 製作轉換的script 


[root@server tmp]# vim convert.sh

#!/bin/sh

set -x

MAILBOX_DIR="/var/spool/mail"
MAILDIR_DIR="/var/spool/maildir"

[ -d $MAILDIR_DIR ] || mkdir -p $MAILDIR_DIR

cd $MAILBOX_DIR

for user in *; do
perl /tmp/mb2md-3.20.pl -s $MAILBOX_DIR/$user -d $MAILDIR_DIR/$user
chown -R $user.mail $MAILDIR_DIR/$user/
done

4. 停止相關服務

 [root@server ~]# service MailScanner stop [root@server ~]# service dovecot stop

5. 調整postfix設定檔
[root@server ~]#  vi /etc/postfix/main.cf

找到
#home_mailbox = Mailbox

改成
home_mailbox = Maildir/

新增
mailbox_command = /usr/bin/procmail -a "$EXTENSION" DEFAULT=/var/spool/maildir/$USER/ MAILDIR=/var/spool/maildir/$USER/

6. 調整dovecot設定檔
[root@server ~]# vi /etc/dovecot/conf.d/10-mail.conf

找到
mail_location = mbox:~/mail:INBOX=/var/mail/%u

改成
mail_location = maildir:/var/spool/maildir/%u

7. 執行script將mailbox轉換成maildir格式

[root@server tmp]# sh convert.sh

8. 停止相關服務
[root@server ~]# service MailScanner start
[root@server ~]# service dovecot start

9. 觀察是否轉換成功
[root@server ~]# ls -l /var/spool/maildir


參考:
http://imomo.tw/phpbb/viewtopic.php?p=19091&sid=0520fa07fc9257233e8bda596afaa9e1

沒有留言:

張貼留言