Transferring from a PST to IMAP Server

Written by James McDonald

September 16, 2015

Step 1: Export from Exchange to PST

A few weeks ago I blogged about Running a Mailbox export from Exchange to PST using powershell at https://toggen.com.au/it-tips/powershell-export-multiple-mailboxes-to-pst

If you are wanting to publish your PST to a IMAP server the next step is to convert the PST file into a format that can be loaded to the aforementioned IMAP server.

libpst has a readpst utility that can export to mbox format.

Initially I installed it on my Mac using homebrew and found that email attachments in the mbox file were corrupted. This was using ReadPST / LibPST v0.6.63 installed with:

brew install libpst

So I downloaded the source from the libpst site (here) and compiled it on my own. I had to do a brew install boost-python to get the dependencies needed. This gave me ReadPST / LibPST v0.6.65 and once I ran it the resulting mbox had uncorrupted attachments.

tar -zxvf libpst-0.6.65.tar.gz
cd libpst-0.6.65
./configure --prefix=$HOME/opt
make
make install

Step 2: Convert from PST to mbox

Important Note: If readpst exits with Segmentation Fault 11 (SIG 11) try using the Windows scanpst.exe utility to rebuild the pst file. This may assist.

Once you have a working readpst. You have a lot of options and switches you can use with it, but I did the following which creates separate mbox files for each Folder.

$HOME/opt/bin/readpst mypst20150826.pst 
Opening PST file and indexes...
Processing Folder "Deleted Items"
Processing Folder "Calendar"
	"Calendar" - 10 items done, 0 items skipped.
Processing Folder "Contacts"
	"Contacts" - 9 items done, 0 items skipped.
Processing Folder "Inbox"
...

Step 2a: Check your mbox is OK

You can test your mbox file by opening the Mac Mail application and importing (File => Import Mailboxes…) the mbox file to check it. You can also use Thunderbird, which is cross-platform but you need to install ImportExportTools

Step 3: Upload to the IMAP Server of your choice

Once you have a good mbox file. You can then download imap_upload.py from http://imap-upload.sourceforge.net/ unzip it and then run the IMAP upload against your mbox file:

# one mbox at a time
python imap_upload.py Archived\ at\ 30_11_2011 \
imap://emailuser:'passw0rd'@email-nas01/Inbox1.Archived
# or if they are all in one directory
# with no other files do it as a multiple
find ./* -type f -prune -print0 | xargs -0 -IFILE python ../imap_upload.py "FILE" imap://imap_user:'imap_pass'@imap_server:/TopFolder.SubFolder

Important Note 2: The folder path you specify ( /Inbox1.Archived ) must exist or imap_upload.py will complain loudly. I created these nested mailboxes on the IMAP server so that the import doesn’t pollute you default inbox. The dot is the heirachy separator

The upload takes a while and depends on your network speed and the ability of both ends and the middle to read, transfer and write quickly. I think on my network it took about 1/2 hour to upload a 1.1G mbox file. This could stretch to days with a big mbox and a slow link.

Important Note 3: After completing the upload access your email on the IMAP server and check the attachments  aren’t corrupted. If they are and you are using an older version of libpst you may need to compile the latest version as above. I compiled the latest and then forgot to call it by its path and picked up the older version which caused a fail.

YMMV

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

How to Research a CPU Upgrade

How to Research a CPU Upgrade

Upgrade Time! Doing a lot of VMWare Workstation virtualization to create labs for self-study and training. Finding...