Roundcube and Home Server Preparation
After logging in to Roundcube, I created a new folder called GMail. This automatically creates the necessary folder structure ready for import.
The easiest way to deal with permissions is to take postfix and dovecot offline whilst I am downloading the e-mail using POP3:
sudo service postfix stop
sudo service dovecot stop
I need to install getmail, create the configuration folder, and create the configuration file:
sudo apt-get update
sudo apt-get install getmail4
type = SimplePOP3SSLRetriever
server = pop.gmail.com
username = firstname.lastname@example.org
password = mypassword
type = Maildir
path = /home/vmail/my.domain/my.mailbox/mail/.GMail/
verbose = 2
message_log = ~/.getmail/gmail.log
I need to take ownership of the mail folder structure in order to prevent permissions errors:
sudo chown thejc:thejc -R /home/vmail/
In GMail Forwarding and POP/IMAP Settings, enable POP for all mail, and choose to delete Gmail's copy when messages are accessed with POP.
Then, run getmail as many times as necessary to download every message:
getmail -r ~/.getmail/getmail.gmail
Repeat that last command as many times is needed until there are zero e-mails downloaded.
At this point change ownership of the mail directories back, restart postfix and dovecot, and check the GMail folder has a load of e-mails in Roundcube.
sudo chown vmail:vmail -R /home/vmail/
sudo service dovecot start
sudo service postfix start
After confirming all the e-mails are there, empty the bin in GMail. Not before making a backup of my home server, that is.