Given the choice, I prefer using an e-mail client in preference to a web browser on whatever machine I am using. Although Google Mail provides an IMAP service, I wanted to be able to keep a copy of my mail on my home server so that I could access Google Mail missives and my various other mail accounts from one source. I would also enjoy the benefit of having a copy of my mail in one easily backup-able and transferable source.
Installing dovecot and getmail:
sudo apt-get install dovecot-common dovecot-imapdc \
Edit the file /etc/dovecot/dovecot.conf
Insert the line:
mail_location = maildir:~/Maildir
sudo /etc/init.d/dovecot restart
You should get a reply:
* Restarting IMAP/POP3 mail server dovecot [ OK ]
Creating your mail directory.
I have set up getmail to keep copies on the Google Mail server for 30 days. I figure that will give me enough resilience :-)
First, make sure that you have POP3 enabled on your Gmail account.
Click on your settings and select the Forwarding and POP/IMAP tab.
Create .getmail directory and rc file.
chmod 700 .
Create a file getmailrc in ~/.getmail.
My getmailrc looks something like this:
type = SimplePOP3SSLRetriever
server = pop.gmail.com
port = 995
username = email@example.com
password = your_password
type = Maildir
path = ~/Maildir/
delete_after = 30
get_all = false
Next all you need to do is schedule getmail to run when you are not looking.
I have set mine to run every 5 minutes.
*/5 * * * * /usr/bin/getmail >/dev/null 2>&1
Connecting to your server.
This is the easy bit.
Using your favorite email client, create an account which uses IMAP. Your server will be localhost (or the IP address of your home server). The user id and passwords are the same as your Ubuntu user account.
Because this is set up on my home network which sits behind a firewall, I have made no provision to employ secure IMAP connections which are, frankly, not needed in this instance as all connections to the IMAP server are made behind the firewall.