Posts filed under ‘Gmail’

Importing mail into Gmail

To import mail into Gmail, the existing Google GMail Loader could be used. This solution works, but since it sends the messages using an SMTP, all dates are reset to the current date. For me, this is very annoying so I searched another solution.
I used the Dovecot IMAP server with secure POP3 access to import my existing mail (from Mozilla Thunderbird, i.e. mbox format) into Gmail. This way, the dates are preserved.

Using Ubuntu Feisty, this is a very simple process:

sudo apt-get install dovecot-imapd dovecot-pop3d

This installs the necessary Dovecot IMAP and POP3 server (version 1.0.rc17). Mails are kept in the mbox file /var/mail/username (got the is info using the script from Dovecot’s wiki).

For Dovecot to work, a configuration file needs to be altered:

sudo pico /etc/dovecot/dovecot.conf

Uncomment ‘protocols’, add pop3 (normal version port 110) and/or pop3s (secure version, port 995):

protocols = pop3 pop3s

The normal pop3 is good in this case, as I tested some things using telnet and the USER/PASS/STAT/RETR commands.

Next, copy the Mozilla Thunderbird mbox file (called ‘Inbox’) to /var/mail. I actually added another user on my Ubuntu system called ‘mboxbackup’, since Gmail will add the existing username in the header of every mail using ‘X-Gmail-Fetch-Info’. Rename the ‘Inbox’ file and chown the file to the newly created user.

Eventually, one could test the newly created pop server from another machine using e.g. telnet. You should get something like this:

$ telnet <ip-address> 110
Trying <ip-address>...
Connected to <ip-address>.
Escape character is '^]'.
+OK Dovecot ready.
USER mboxbackup
+OK
PASS <password>
+OK Logged in.
STAT
+OK 1007 84278254
RETR 1
+OK 3859 octets
X-Account-Key: account2
<snip>

Only 1007 mails are on my POP3 server now, since I broke up my existing Mozilla Thunderbird mbox file to test (very easy, just create a folder in Thunderbird, copy or move the messages into it and off you go!). Gmail shouldn’t have problems importing any amount of mails since maximum 200 messages are fetched at once.

I restarted Dovecot (I used ‘killall dovecot’ to stop).

In Gmail, go to ‘Settings’ –> ‘Accounts’ and choose ‘Add another mail account’. As your email address, anything could be entered. In the next step, enter the username and password, choose ‘Always use a secure connection (SSL) when retrieving mail’, enter ‘995‘ as port and eventually choose a label.

Voila! Importing should start, 200 mails will be pulled every time. Dates should be kept as the original ones.

Note that e.g. 10000 imported mails will probably not result in 10000 mails in your Gmail inbox, since Gmail tries to make threads of replies and answers automatically. Check your spam folder too.

May 18, 2007 at 5:44 pm 2 comments


Calendar

June 2017
M T W T F S S
« Jan    
 1234
567891011
12131415161718
19202122232425
2627282930  

Posts by Month

Posts by Category