bluebird75 / maildir2mbox Goto Github PK
View Code? Open in Web Editor NEWConvert mailbox from maildir format to mbox format
License: The Unlicense
Convert mailbox from maildir format to mbox format
License: The Unlicense
I get the following when running python maildir2mbox --help:
File "maildir2mbox.py", line 30
print(prefix, *args)
^
SyntaxError: invalid syntax
Dear bluebird75,
The script is throwing an error.
23:50:28 Progress: msg 173400 of 225509
23:50:29 Progress: msg 173500 of 225509
ERROR 23:50:29 Exception while processing msg with key: 1642324253.M699656P643386.mail,S=3478,W=3548
Traceback (most recent call last):
File "/Volumes/T7 Touch/MailArchive/maildir2mbox.py", line 205, in <module>
convert(Path(args.maildir_path), Path(args.mbox_filename), bool(args.recurse))
File "/Volumes/T7 Touch/MailArchive/maildir2mbox.py", line 105, in convert
result = maildir2mailbox(maildir_path, mbox_path)
File "/Volumes/T7 Touch/MailArchive/maildir2mbox.py", line 81, in maildir2mailbox
mbox.add(msg)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/mailbox.py", line 606, in add
self._toc[self._next_key] = self._append_message(message)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/mailbox.py", line 761, in _append_message
offsets = self._install_message(message)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/mailbox.py", line 833, in _install_message
self._dump_message(message, self._file, self._mangle_from_)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/mailbox.py", line 216, in _dump_message
gen.flatten(message)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/email/generator.py", line 116, in flatten
self._write(msg)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/email/generator.py", line 181, in _write
self._dispatch(msg)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/email/generator.py", line 218, in _dispatch
meth(msg)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/email/generator.py", line 268, in _handle_multipart
self.write(subparts)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/email/generator.py", line 410, in write
self._fp.write(s.encode('ascii', 'surrogateescape'))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 532-537: ordinal not in range(128)
Is there any way to fix it?
Windows 7 x64, Python 3.8.1, script has been downloaded to C:\Python\Scripts, then
$ py maildir2mbox.py c:\MailOld\Trash c:\MailNew\Trash
2020-03-15 15:09:27 Russia TZ 2 Standard Time [INFO ] c:\MailOld\Trash -> c:\MailNew\Trash
Traceback (most recent call last):
File "maildir2mbox.py", line 131, in <module>
main(args.maildir_path, args.mbox_filename)
File "maildir2mbox.py", line 86, in main
maildir2mailbox(dirname, mboxname)
File "maildir2mbox.py", line 42, in maildir2mailbox
mails = len(maildir)
File "C:\Python\lib\mailbox.py", line 412, in __len__
self._refresh()
File "C:\Python\lib\mailbox.py", line 529, in _refresh
mtime = os.path.getmtime(self._paths[subdir])
File "C:\Python\lib\genericpath.py", line 55, in getmtime
return os.stat(filename).st_mtime
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'c:\\MailOld\\Trash\\new'
Contents
MailOld
└── Trash
├── cur
│ └── zyedidia%2fmicro%2freleases%[email protected]
└── tmp
How do I proceed?
Hi, I am using this very nice tool to convert a batch of old directories with mail in Maildir format to a mailbox format for archiving. However, I have noticed that each conversion leaves a *.sbd directory around. Is this intentional? The original tool by Frederic would remove the directory.
Hello,
first thank you for this script! I had a much harder time than expected to import maildir into Thunderbird without a detour through an imap server, and this script is the one I found!
I use the latest version 1.0 from april 21st of 2020, and I have the "official" maildir format (screenshot)
When using maildir2mbox.py -r Maildir_old/ mboxX
(using 22.04 and python 3.10.6), I get
maildir2mbox_orig.py -r Maildir_old/ mboxX
ERROR 15:32:49 Missing `new` and/or `cur` subdirectories in path Maildir_old, aborting conversion
15:32:49 Maildir_old/.HO restructuring -> mboxX.sbd/HO restructuring
15:32:49 Processing 77 messages in Maildir_old/.HO restructuring
15:32:49 Maildir_old/.HO restructuring.AS -> mboxX.sbd/HO restructuring.AS #<-- the folder should be calld AS.sbd and be in HO restructuring
15:32:49 Processing 16 messages in Maildir_old/.HO restructuring.AS #<-- the emails should be moved inside HO restructuring/ in a file AS
15:32:49 Done with 1 errors. # can be ignored I think
I also tested it with the provided test_data and if I e.g. move the .coincoin
folder to the same level as the .INBOX.toto
folder (and rename it to .INBOX.toto.coucou
) it also wrongly gets placed next to .INBOX.toto
(and not inside .INBOX.toto
).
I think the problem lies in maildir_sub_path
(? or of course, I wrongly apply the script) and I tried to debug it in an online python debugger but had troubles getting the correct variable (path info) of maildir_path to be used. I'm happy to investigate further, e.g. if somebody tells me how I can use a variable depending on a local folder inside an online debugger.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.