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

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