{"id":305,"date":"2014-10-26T14:27:05","date_gmt":"2014-10-26T06:27:05","guid":{"rendered":"http:\/\/192.168.0.1\/blog_4.4.2\/?p=305"},"modified":"2014-10-26T14:30:17","modified_gmt":"2014-10-26T06:30:17","slug":"aakpostfix-lyoaeyn-mbox-aa-maildir","status":"publish","type":"post","link":"https:\/\/blog.worren.net\/?p=305","title":{"rendered":"[\u8f49\u8cbc]Postfix \u90f5\u4ef6\u683c\u5f0f\u7531 mbox \u8f49 maildir"},"content":{"rendered":"<div class='drop-case'> <p> \u89e3\u6c7a\u4e00\u4e0b Mail Server \u6548\u80fd\u554f\u984c ! .. \u8a66\u8a66\u770b\u9019\u500b\u6771\u897f\u884c\u4e0d\u884c !<\/div>\n <p> \u8f49\u8cbc\u81ea&#8230; <br \/> \n<a href=\\\"http:\/\/blog.infinity.idv.tw\/index.php\/2010\/10\/25\/postfix-%E9%83%B5%E4%BB%B6%E6%A0%BC%E5%BC%8F%E7%94%B1-mbox-%E8%BD%89-maildir\/\\\"> <br \/> \nhttp:\/\/blog.infinity.idv.tw\/index.php\/2010\/10\/25\/postfix-%E9%83%B5%E4%BB%B6%E6%A0%BC%E5%BC%8F%E7%94%B1-mbox-%E8%BD%89-maildir\/ <br \/> \n<\/a>\n <p> 2010-10-27\n <p> mbox \u8207 maildir \u512a\u7f3a\u9ede\u6bd4\u8f03: <br \/> \n <!--more-->  <br \/> \n===========================================================\n <p> mbox \u8207 maildir \u4e4b\u512a\u7f3a\u9ede\u6bd4\u8f03\n <p> \u9019\u88e1\u7d66\u51fa\u4e00\u500b\u57fa\u672c\u7684\u7279\u6027\u5c0d\u6bd4\uff0c\u5f88\u5bb9\u6613\u5c31\u80fd\u6e05\u695a\u81ea\u5df1\u7684\u7a0b\u5f0f\u61c9\u8a72\u9078\u4ec0\u9ebc\u5b58\u5132\u683c\u5f0f:\n <p> \u53ef\u9760\u6027\n <p> \u512a\u9078\u662f maildir\uff0c\u56e0\u70ba mbox \u53ea\u6709\u4e00\u500b\u6a94\u6848\uff0c\u4e00\u65e6\u51fa\u554f\u984c\uff0c\u6240\u6709\u90f5\u4ef6\u53ef\u80fd\u4e00\u4f75\u640d\u6bc0\u3002\n <p> \u66f4\u65b0\u6548\u80fd\n <p> \u9019\u88e1\u4e3b\u8981\u6307\u7684\u662f\u522a\u9664\/ \u589e\u52a0\u90f5\u4ef6\u7684\u80fd\u529b\uff0c\u7121\u7591 maildir \u5b8c\u52dd mbox\n <p> \u641c\u5c0b\u901f\u5ea6\n <p> \u9019\u9ede mbox \u56e0\u70ba\u662f\u55ae\u6a94\u6848\uff0c\u641c\u5c0b\u80fd\u529b\u8981\u5f37\u65bc maildir\n <p> \u4e26\u884c\u5b58\u53d6\u80fd\u529b\n <p> \u5c0d\u65bc\u7e41\u5fd9\u7684\u90f5\u4ef6\u7cfb\u7d71\uff0c\u591a\u500b Process \u540c\u6642\u5b58\u53d6\u540c\u4e00\u5c01\u90f5\u4ef6\u662f\u53ef\u80fd\u7684\u4e8b\u60c5\uff0cmbox \u9700\u8981 flock() \u7684\u652f\u63f4\uff0c\u800c\u4e14\u5982\u679c\u67d0\u4e00\u500b Process \u64cd\u4f5c\u6642\u9593\u9577\uff0c\u5247\u5176\u4ed6\u6240\u6709 Process \u90fd\u5835\u585e\u4e86\u3002maildir \u6c92\u6709\u9019\u500b\u554f\u984c\u3002\u5728 NFS \u7b49\u7db2\u8def\u6a94\u6848\u7cfb\u7d71\u4e0a\uff0cmaildir \u76f8\u5c0d\u5b89\u5168\uff0cmbox \u5247\u4e0d\u80fd\u7528\u65bc\u6b64\u985e\u578b\u74b0\u5883\n <p> \u64f4\u5145\u80fd\u529b\n <p> \u73fe\u4e0b\u7684\u90f5\u7bb1\u5bb9\u91cf\u5df2\u7d93\u4e0d\u662f\u5341\u5e74\u524d\u7684 MB, \u800c\u662f GB\uff0cmbox \u61c9\u4ed8\u5927\u5bb9\u91cf\u5df2\u529b\u4e0d\u5f9e\u5fc3\uff0c\u7121\u7591 maildir \u662f\u6bd4\u8f03\u9069\u5408\u7684\u3002\n <p> \u6a94\u6848\u7cfb\u7d71\u501a\u8cf4\n <p> maildir \u8f03\u501a\u8cf4\u6a94\u6848\u7cfb\u7d71\u7684\u7d22\u5f15\u80fd\u529b\uff0c\u7528 ReiserFS \u6703\u6bd4\u8f03\u5feb\uff0c\u5c0d\u65bc\u8d85\u5927\u578b\u7684 maildir\uff0c\u8b80\u5beb\u6027\u80fd\u5c07\u53d7\u5230\u8003\u9a57\u3002\u76f8\u5c0d\u800c\u8a00 mbox \u5247\u4e0d\u5b58\u5728\u9019\u500b\u554f\u984c\u3002\n <p> \u7e3d\u5408\u7d50\u8ad6\n <p> \u4f7f\u7528 maildir \u683c\u5f0f\uff0c\u5b89\u5168\u53ef\u9760\uff0c\u5927\u90e8\u5206\u64cd\u4f5c\u90fd\u5feb\u65bc mbox\u3002\u800c\u4e14\u73fe\u4eca\u652f\u63f4 maildir \u7684\u8edf\u9ad4\u8d8a\u4f86\u8d8a\u591a\u3002\n <p> ===========================================================\n <p> 2010-10-26\n <p> 1.\u8f49\u63db\u4fe1\u4ef6\u5f8c\u8b8a\u6210\u4e00\u5c01\u4fe1\u4e00\u500b\u6a94\u6848\uff0c\u56e0\u6b0a\u9650\u6c92\u6b63\u78ba\u4fee\u6539\u597d\uff0c\u6545\u624b\u52d5\u4fee\u6b63\u4e86\u597d\u4e00\u9663\u5b50 >_<\n\n2.\n\/var\/spool\/maildir\/\u5e33\u865f\/cur <=\u770b\u904e\u7684\u4fe1\u5982\u679c\u9084\u4fdd\u7559\u5728SERVER\u4e0a\u7684\u4fe1\u5c31\u5b58\u9019\n\/var\/spool\/maildir\/\u5e33\u865f\/new <=\u65b0\u9032\u7684\u4fe1\u9084\u6c92\u770b\u904e\u5c31\u5b58\u9019\n\/var\/spool\/maildir\/\u5e33\u865f\/tmp <=\u6536\u4fe1\u4ef6\u66ab\u5b58\u5340\uff0c\u6536\u5b8c\u4fe1\u5f8c\u624d\u79fb\u5230new\n\n3.\u63db\u4e86\u9019\u500bmaildir\u683c\u5f0f\u5f8c\uff0c\u611f\u89baMAIL SERVER\u5f88\u9806\uff0c\u4ee5\u524d\u6536\u767c\u90fd\u6703\u5361\uff0c\u53ef\u80fd\u5c31\u662f\u56e0\u70bambox\u7684LOCK\u6a5f\u5236\u9020\u6210\u3002\n\n4.\u7528maildir\u683c\u5f0f\u8981\u662f\u4f7f\u7528\u8005\u4eba\u5f88\u591a,\u4e14\u90fd\u6709\u7559\u5e7e\u5929\u4fe1\u5728SERVER\u4e0a\u7684\u7fd2\u6163\uff0c\u90a3\u8981\u7279\u5225\u7559\u610f\u6a94\u6848\u6578\u91cf\u8207 Inode \u6578\u91cf\uff0c\u8d85\u904e\u5c31\u7121\u6cd5\u5728\u5beb\u5165\u78c1\u789f\u3002\n\n[root@mail ~]# df -i\n\u6a94\u6848\u7cfb\u7d71              Inode    I\u5df2\u7528  I\u53ef\u7528 I\u5df2\u7528% \u639b\u8f09\u9ede\n\/dev\/sda1            3840192   24549 3815643    1% \/\n\/dev\/sda6            98074624   10654 98063970    1% \/var\n\/dev\/sda3            2560864  117080 2443784    5% \/usr\n\/dev\/sda2            25624576   10116 25614460    1% \/home\ntmpfs                 221892       1  221891    1% \/dev\/shm\n\n \n\n2010-10-25\n\nPostfix \u90f5\u4ef6\u683c\u5f0f\u7531 mbox \u8f49 maildir \uff0cmaildir\u683c\u5f0f\u53ef\u907f\u514dmbox\u683c\u5f0f LOCK\u9396\u6a94\u6848\u9020\u6210 aliases \u7684\u7fa4\u7d44\u4eba\u54e1\u91cd\u8907\u6536\u5230\u4fe1\u3002\n\n\u683c\u5f0f\u8aaa\u660e\u51fa\u8655:http:\/\/www.creativecrap.com\/story\/software\/mbox-to-maildir\n\n========================================\nmbox mail storage format\n\n\u9019\u662f\u50b3\u7d71\u7684\u90f5\u4ef6\u683c\u5f0f\uff0c\u5c07\u6240\u6709\u7684\u4fe1\u4ef6\u90fd\u5b58\u5728\u4e00\u500b\u6a94\u6848\u4e2d\uff0c\u6240\u4ee5\u76f8\u5c0d\u7684\u6703\u6709\u5f88\u591a\u7684\u7f3a\u9ede\uff0c\u5305\u542b\u7576\u6a94\u6848\u592a\u5927\u6642\u5b58\u53d6\u7684\u6548\u7387\u5373\u8b8a\u5dee\uff0c\u82e5\u90f5\u4ef6\u6a94\u640d\u6bc0\u5247\u6240\u6709\u7684\u4fe1\u4ef6\u90fd\u6c92\u4e86\uff0c\u540c\u6642\u53ea\u80fd\u6709\u4e00\u500b process \u5b58\u53d6\uff0c\u7b2c\u4e8c\u500b process \u9808\u7b49\u7b2c\u4e00\u500b unlock \u4e4b\u5f8c\uff0c\u624d\u80fd\u5b58\u53d6\u3002\u512a\u9ede\u61c9\u8a72\u662f\u7c21\u55ae\uff0c\u55ae\u4e00\u6a94\u6848\u641c\u5c0b\u6642\u8f03\u5feb\uff0c\u5927\u90e8\u4efd\u9810\u8a2d\u503c\u90fd\u9084\u662f mbox\uff0c\u5099\u4efd\u6642\u4e5f\u65b9\u4fbf\uff0c\u56e0\u70ba\u53ea\u6709\u4e00\u500b\u6a94\u6848\u3002\nmaildir mail storage format\n\n\u9019\u5c31\u662f\u6bd4\u8f03\u65b0\u7684\u683c\u5f0f\uff0c\u6c92\u8a18\u932f\u7684\u8a71\u65e9\u5148\u662f\u7531 Qmail \u958b\u59cb\u4f7f\u7528\u3002\u5c07\u6bcf\u4e00\u5c01\u4fe1\u4ef6\u5c31\u55ae\u7368\u5b58\u6210\u4e00\u500b\u6a94\u6848\u3002\u76f8\u5c0d\u65bc mbox \u7684\u7f3a\u9ede\u5373 maildir \u7684\u512a\u9ede\uff0c\u53cd\u904e\u4f86\u641c\u5c0b\u901f\u5ea6\u5c31\u662f maildir \u7684\u7f3a\u9ede\u4e86\u3002\n\n========================================\n\n\u4ee5\u4e0b\u662f\u770b\u65d7\u6a19 Linux Mail Server \u6280\u8853\u5be6\u52d9\u4f86\u6e2c\u8a66\u8f49\u63db(\u56e0\u81ea\u67b6MAIL SERVER\u65bcVM\u4e2d\uff0c\u6545\u5148\u884c\u5feb\u7167\uff0c\u907f\u514d\u6709\u554f\u984c\u6642\u53ef\u56de\u5fa9\u539f\u72c0)\n\n\u505c\u6b62 MTA \u670d\u52d9(Mailscanner)\n[root@mail ~]# \/etc\/init.d\/MailScanner stop\nShutting down MailScanner daemons:\n         MailScanner:                                      [  \u78ba\u5b9a  ]\n         incoming postfix:                                 [  \u78ba\u5b9a  ]\n         outgoing postfix:                                 [  \u78ba\u5b9a  ]\n\n[root@mail ~]# \/etc\/init.d\/dovecot stop\n\u6b63\u5728\u505c\u6b62 Dovecot Imap:                                     [  \u78ba\u5b9a  ]\n\n\u5efa\u7acb maildir \u683c\u5f0f\u5b58\u653e\u76ee\u9304:\n[root@mail ~]# mkdir \/var\/spool\/maildir\n\n\u67e5\u770b\u539f\u5148mbox\u5b58\u653e\u76ee\u9304\u7684\u64c1\u6709\u8005\n[root@mail ~]# ls -ld \/var\/spool\/mail\ndrwxrwxr-x 2 root mail 4096  1\u6708 27  2010 \/var\/spool\/mail\n\n\u5efa\u7acb maildir \u8207 mbox \u76ee\u9304\u4e00\u6a23\u7684\u64c1\u6709\u8005\u6b0a\u9650\n[root@mail ~]# chown root.mail \/var\/spool\/maildir\/\n\n\u5efa\u7acb maildir \u76ee\u9304\u5b58\u53d6\u6b0a\u9650\n[root@mail ~]# chmod 1777 \/var\/spool\/maildir\/\n\n\u4fee\u6539 vi \/etc\/postfix\/main.cf\n[root@mail ~]# vi \/etc\/postfix\/main.cf\n\u2026\u2026\u2026\nhome_mailbox = Maildir\/\nmail_spool_directory = \/var\/spool\/maildir\/\nmailbox_command = \/usr\/bin\/procmail -a \\\"$EXTENSION\\\" DEFAULT=\/var\/spool\/maildir\/$USER\/ MAILDIR=\/var\/spool\/maildir\/$USER\/ <==\u6307\u5b9a\u6536\u4ef6\u8def\u5f91\uff0c\u4e0d\u6307\u5b9a\u6703\u9001\u5230mbox\u4fe1\u7bb1\n\u2026\u2026\u2026\n\n\u4fee\u6539 vi \/etc\/dovecot.conf\n[root@mail ~]# vi \/etc\/dovecot.conf\n\u2026\u2026\nmail_location = maildir:\/var\/spool\/maildir\/%u (\u66f8\u4e0a\u5beb\u7684\u662f default_mail_env = maildir:\/var\/spool\/maildir\/%u\uff0c\u4e0d\u904e\u88e1\u9762\u662f\u5beb\u6211\u524d\u9762\u7684\u6a23\u5f0f\u3002)\n\u2026\u2026\n\n\u5c07mbox\u8f49maildir\u683c\u5f0f:\n\n\u5b89\u88ddperl-5* perl-TimeDate*\nyum install perl-5* perl-TimeDate*\n\n\u4e0b\u8f09\u5b89\u88dd mb2md\n[root@mail ~]# wget http:\/\/batleth.sapienti-sat.org\/projects\/mb2md\/mb2md-3.20.pl.gz\n[root@mail ~]# gzip -d mb2md-3.20.pl.gz\n[root@mail ~]# chmod +x mb2md-3.20.pl\n[root@mail ~]# mv mb2md-3.20.pl \/usr\/local\/bin\/mb2md\n\n\u5efa\u7acb mbox \u8f49 maildir \u6279\u6b21\u57f7\u884c\u6a94:\nvim \/usr\/local\/bin\/allmb2md\n==================================\n#!\/bin\/sh\n\n#\u8a2d\u5b9a\u539f\u672cmbox\u683c\u5f0f\u90f5\u4ef6\u76ee\u9304\nMBOXDIR=\\\"\/var\/spool\/mail\\\"\n\n#\u8a2d\u5b9amaildir\u683c\u5f0f\u76ee\u9304\nMAILDIR=\\\"\/var\/spool\/maildir\\\"\n\ncd $MBOXDIR\n\nfor user in *; do\n  mkdir -p $MAILDIR\/$user\n  mb2md -s $MBOXDIR\/$user -d $MAILDIR\/$user\/\n  chmod -R 700 $MAILDIR\/$user\/\n  chown $user.mailuser $MAILDIR\/$user\/   <==\u9019\u908a\u82e5\u4f7f\u7528\u8005\u540d\u7a31\u70ba \u540d.\u59d3 Roger.Lin \u5247\u8981\u4f7f\u7528 :\u865f\u5340\u9694\u7fa4\u7d44  Roger.Lin:mailuser\ndone\n===================================\n\n\u7d66\u6b0a\u9650\n[root@mail ~]# chmod +x \/usr\/local\/bin\/allmb2md\n\n\u57f7\u884c\u8f49\u63db\n[root@mail ~]# allmb2md\n\n\n","protected":false},"excerpt":{"rendered":" <p> \u89e3\u6c7a\u4e00\u4e0b Mail Server \u6548\u80fd\u554f\u984c ! .. \u8a66\u8a66\u770b\u9019\u500b\u6771\u897f\u884c\u4e0d\u884c ! \u8f49\u8cbc\u81ea&#8230; http:\/\/blog.infinity.idv.tw\/index.php\/2010\/10\/25\/postfix-%E9%83%B5%E4%BB%B6%E6%A0%BC%E5%BC%8F%E7%94%B1-mbox-%E8%BD%89-maildir\/ 2010-10-27 mbox \u8207 maildir \u512a\u7f3a\u9ede\u6bd4\u8f03: <\/p> \n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.worren.net\/index.php?rest_route=\/wp\/v2\/posts\/305"}],"collection":[{"href":"https:\/\/blog.worren.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.worren.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.worren.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.worren.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=305"}],"version-history":[{"count":0,"href":"https:\/\/blog.worren.net\/index.php?rest_route=\/wp\/v2\/posts\/305\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.worren.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.worren.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.worren.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}