Is there any way to import a mbox file from gmail?

Hi! I was just wondering if there is any way to import messages from gmail backup file (.mbox) - I need to import e-mails from a google apps account and imap syncronization tools (such as imapsync) don’t work on my case.
Regards;

You could try using a Thunderrbird Portable instance in windows …

  • Config. your GSuite (Old Gapps) account(s) in thunderbird as POP and download your mails.
  • Config. your BOX accounts in Thunderbird as IMAP
  • Copy your earlier downloaded emails from your Gapps account(s) to the equivalent account/ folder(s) in BOX ones… All emails will be uploaded to your BOX ones.
1 Like

Thank you, it works!

I needed to import a lot of very huge mbox files (4GB or more). I ended up sending all mbox files to the mail server using SSH and creating a small script to import them. It is just a copy-and-paste of Roundcube’s source code that handles the importing of mbox files, adapted to be used in the terminal.

For everyone who finds themselves in a similar situation, here it is: https://gist.github.com/leda-ferreira/60efee6a8b73cc118f521f89ccb22957

All you need to do is paste the code from the above gist in a new file (say, import.php), place it in Roundcube’s root directory (/usr/local/lib/roundcubemail), and execute it like this:

php import.php EMAIL PASSWORD /path/to/file.mbox

That will do the trick.

1 Like

I was able to migrate emails from a gmail mbox file using the scripts in this repo: https://github.com/danburzo/gmail-mbox2maildir.git

I first uploaded the gmail .mbox file to my mailinabox server (using scp), then split the mbox file into the corresponding folders using mbox_split.py, then extracted the mbox files into maildir format using mb2md.pl, then copied the maildir files into the relevant dir within /home/user-data/mail/mailboxes/.

I suggest you download the most usable CubexSoft MBOX to Gmail Converter tool through which you can easily get all your MBOX files in your Gmail account directly and safely. There is no need to have the technical knowledge to process your MBOX files through the help of this tool.