The format for that conversion is not that complicated and an MBOX file should be automatically generated from any number of EML files with a shell loop like this (ensure no file named file.mbox
exists in the same directory before running it):
for e in *.eml
do
date +"From - %a %b %d %H:%M:%S %Y" >> file.mbox
cat "$e" >> file.mbox
echo >> file.mbox
done
... that when run from within the directory containing the *.eml
files, should at the end create a file named file.mbox
in the same directory.
TLR :)
All the important information i.e. message headers and message body should be contained in each EML file .eml
following an EML standard defined since 1982 upon which most of the email clients based their parsing/processing of email message files and that in most cases should keep the integrity of both the headers containing among which the sender's email and timestamps as well as the message body.
The MBOX file format, on the other hand was not standardized until more than two decades later ... In its essence, it is a sort of a single container for multiple email messages (that should follow standardized EML format).
However, The current MBOX File Format "standard" (as of 2005) is simply as follows:
First, From
that is F
, r
, o
and m
followed by a single space then an email address of some kind and then another single space followed by a time-stamp followed by an end of the line indicator and immediately on the next line (no blank line expected), the message should start and then it should end with a blank line (no space or tabs, just a blank line) ... Then that format is repeated throughout the MBOX file and email clients should parse the file until there is no more data left or an end-of-file is reached.
I remember having to deal with such an issue quiet a long while ago and if I recall correctly the From
line I used in the generated MBOX file looked like this:
From - Tue Nov 21 17:30:08 2023
... which is AFAIK is mostly overlooked by email apps and is added here as a record separator, and any timestamp should work for this purpose (it might be possible that your mail client will offer repairing those lines if it needs to).
for e in *.eml; do date +"From - %a %b %d %H:%M:%S %Y" >> file.mbox; cat "$e" >> file.mbox; echo >> file.mbox; done
might do the job. – Raffa Nov 21 '23 at 14:34