Migrating/Importing IMAP email to Gmail
About a month ago, I started using Google to host my domain's email (ie, webworksllc.com). They host your domain email for free, using the same gmail interface that everyone loves.
The problem is, it's not super easy to migrate email from your old account to google.
There is a tool called the Gmail Loader (GML) that can handle all kinds of mail formats for mail stored on your desktop. For example, if you use Thunderbird or Netscape to download your email via POP3, it stores that mail in files called "mbox" files, and GML can handle those.
If you're using Outlook, your mail is stored in special files called PST files, and you'll have to use a utility called "ReadPST" to convert them to mbox format files before GML can load them into google.
But if you're using webmail - or if you're like me and you use IMAP to store your email, then the mail is not stored on your local desktop.
One option - if you're using Thunderbird - is to copy your entire account - all of the folders - to your Local Folders. This causes thunderbird to download *ALL* of the mail and store it locally in mbox files. You can then use Gmail Loader. Another option would be to ask your provider to zip your entire domain's mail files and send them to you - AFTER you go through and do your domain and account setup on google. Then you can use gmail on those files (probably maildir formatted files, which Gmail Loader also supports)
But if you're running your own server, and you're using qmail - there's an easier way. I created a little script called "sendtogmail.sh".
This only works AFTER you've set up google mail for your domain completely, set up the accounts, and changed the DNS. You must also have configured qmail to no longer think it accepts mail for your domain - by removing it from /var/qmail/control/rcpthosts
I wrote a little script called sendtogmail.sh and this is what it looks like:
CNT=0
for X in 1*
do
cat $X | /var/qmail/bin/qmail-inject -A -f rick@webworksllc.com rick@webworksllc.com
CNT=$((CNT+1))
rm -f $X
echo $CNT
done
There's probably a better way to do it, but I put this script into /usr/local/bin and permed it executable. Then I just change into each directory where mail is stored, and run it. It uses qmail-inject to inject the original mail file back into the mail queue. The -A option causes it to only use the recipient specified in the command line, and the -f option specifies the envelope sender (don't worry, it won't have any affect on the "From" of the message itself. After each message, it outputs a current count, and then removes the message (which is unnecessary, really)
It works quite quickly, because qmail is VERY good at sending mail! It's *MUCH* faster than GML too, which seemed to take about 3-5 seconds per message, and I was able to do thousands of messages in only a few minutes.
You are not logged in, so your subscription status for this entry is unknown. You can login or register here.
Am i supposed to strip these lines out or something?
You should mention to remove the domain from the /var/qmail/control/virtualdomains file as well as rcpthosts then do a /var/qmail/qmailctl reload before executing the script.