我正在改变主机,我需要将旧服务器上的maildir帐户转换为新服务器上的mbox。
有什么最好的办法吗?
我发现了这个:
适用于新/*cur/*中的I;请执行formail <“$i”>> ./mbox;已完成
但我不太明白。我对linux有基本的了解,我可以通过ssh访问我的服务器。
大多数Maildir文件夹的内容如下:
库尔
新的
tmp
dovecot.index.log
多维科特
dovecot.index
dovecot.index.log.2
dovecot.index.cache
dovecot-关键词
订阅
我需要所有这些,还是可以忽略dovecot文件?
如有任何建议,将不胜感激。
C
发布于 2010-03-25 06:21:41
如果您可以通过imap访问这两个服务器(或者可以临时安排),您可能需要考虑使用imapsync工具,例如:
http://freshmeat.net/projects/imapsync/
如果这样做不起作用,您应该能够忽略dovecot文件,但请注意,您可能会丢失诸如读取哪些消息和设置在消息上的任何标志之类的信息。( imapsync方法将保留所有这些内容。)
发布于 2012-01-19 17:01:22
如果需要在不设置邮件服务器的情况下将maildir帐户转换为邮箱帐户,则可以使用python的邮箱库。如果有一个要转换的maildir文件夹,可以使用这个小的(10 lines+comments) python脚本找到这里。如果有子文件夹,则需要探索子文件夹结构,这在两种格式之间是不同的。这给出了以下脚本:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Frédéric Grosshans, 19 January 2012
Nathan R. Yergler, 6 June 2010
This file does not contain sufficient creative expression to invoke
assertion of copyright. No warranty is expressed or implied; use at
your own risk.
---
Uses Python's included mailbox library to convert mail archives from
maildir [http://en.wikipedia.org/wiki/Maildir] to
mbox [http://en.wikipedia.org/wiki/Mbox] format, icluding subfolder.
See http://docs.python.org/library/mailbox.html#mailbox.Mailbox for
full documentation on this library.
---
To run, save as md2mb.py and run:
$ python md2mb.py [maildir_path] [mbox_filename]
[maildir_path] should be the the path to the actual maildir (containing new,
cur, tmp, and the subfolders, which are hidden directories with names like
.subfolde.subsubfolder.subsubsbfolder);
[mbox_filename] will be newly created, as well as a [mbox_filename].sbd the
directory.
"""
import mailbox
import sys
import email
import os
def maildir2mailbox(maildirname, mboxfilename):
"""
slightly adapted from maildir2mbox.py,
Nathan R. Yergler, 6 June 2010
http://yergler.net/blog/2010/06/06/batteries-included-or-maildir-to-mbox-again/
"""
# open the existing maildir and the target mbox file
maildir = mailbox.Maildir(maildirname, email.message_from_file)
mbox = mailbox.mbox(mboxfilename)
# lock the mbox
mbox.lock()
# iterate over messages in the maildir and add to the mbox
for msg in maildir:
mbox.add(msg)
# close and unlock
mbox.close()
maildir.close()
#Creates the main mailbox
dirname=sys.argv[-2]
mboxname=sys.argv[-1]
print(dirname +' -> ' +mboxname)
mboxdirname=mboxname+'.sbd'
maildir2mailbox(dirname,mboxname)
if not os.path.exists(mboxdirname): os.makedirs(mboxdirname)
listofdirs=[dn for dn in os.walk(dirname).next()[1] if dn not in ['new', 'cur', 'tmp']]
for curfold in listofdirs:
curlist=[mboxname]+curfold.split('.')
curpath=os.path.join(*[dn+'.sbd' for dn in curlist if dn])
if not os.path.exists(curpath): os.makedirs(curpath)
print('| ' +curfold +' -> '+curpath[:-4])
maildir2mailbox(os.path.join(dirname,curfold),curpath[:-4])
print('Done')发布于 2022-03-28 12:22:48
如果您有Maildir文件数据,并且希望将Maildir文件导入MBOX帐户,那么您可以借助任何第三方工具将Maildir文件导入MBOX帐户。但在我看来,您应该使用此Maildir到MBOX转换器工具的免费试用版,该工具只需简单简单地单击就可以将单个和多个Maildir文件导入MBOX帐户。
https://stackoverflow.com/questions/2501182
复制相似问题