In Dynamic DNS with 1&1, I wrote about how I host a site on a server with a dynamic IP address (such as a server on a typical home connection).
The shortcomings of the 1&1-based service:
- No IMAP access to e-mail. 1&1 only provides POP access (no SSL, either). POP is no good for multiple points of presence (checking mail from a phone would interfere on the “headless” downloading of mail at home).
- Very limited number of subdomains. Ridiculously, 1&1 only provides for 5 subdomains per 1&1 account (not per domain, per 1&1 account).
The above was written before Google Apps For Your Domain became widely available. 1&1′s $8.99 is still the cheapest registration out there – it gets you one year of registration with private WHOIS registration included. Other closely-priced offerings charge extra for the private WHOIS registration. With Google Apps, e-mail and DNS services can be separated from the low-cost 1&1 domain registration:
- MX records can be pointed to Google Apps
- DNS can then be delegated elsewhere to any of the numerous FreeDNS services (I will likely select http://freedns.afraid.org/, Namecheap, or maybe EveryDNS – recommendations are welcome).
Today we talk about configuring a home Linux system for use with Google Apps for e-mail in a way that still provides for web-based access to the same e-mail account (home download of e-mail shouldn’t cause mail to appear as “read” by the webmail client).
Getmail
I like getmail for mail download. It is an easy-to-configure alternative to fetchmail. Google provides the bare-bones “Configuring other mail clients”, but leaves it to you to figure out the exact configuration. Create a $HOME/.getmail/getmailrc:
[retriever]
type = SimpleIMAPSSLRetriever
server = imap.gmail.com
port = 993
username = username@gmail.com
password = #####
mailboxes = ('I',)
[destination]
...
[options]
read_all = False
delivered_to = False
delete = True
The interesting bits:
- I set up the Gmail account with a filter that adds the “I” label to all incoming e-mail (the e-mail I want to eventually download with getmail).
- getmail is configured to download mail from the “I” folder (Gmail labels are IMAP folders).
- getmail is configured to delete read mail. Gmail treats an IMAP delete as an “unlabel” operation (mail isn’t actually deleted unless it is moved to the “Trash” folder.
The result:
- getmail can download mail all day.
- The Gmail web interface can be used to read mail without confusing getmail about what has been seen and what has not been seen. Furthermore, normal Gmail filters can be used independently of getmail (as long as the magic “I” labeling is not interfered with).
- As a side-effect, the presence of the “I” labels is a visible indicator of getmail activity.
Postfix
For outbound mail (SMTP), most Linux (and Mac OS X) systems will use postfix. ISPs will direct you to use their SMTP servers. This is fine, but one loses the nicety that sent mail will not appear in the Gmail “Sent Mail” folder. Getting this kind of clean integrated “Sent Mail” behavior requires that outbound mail go through Google’s SMTP servers.
In /etc/postfix/main.cf:
relayhost = [smtp.gmail.com]:587 smtp_sasl_auth_enable = yes smtp_sasl_security_options = noanonymous smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_password smtp_use_tls = yes smtp_tls_CAfile = /etc/ssl/certs/Thawte_Premium_Server_CA.pem
In /etc/postfix/sasl/sasl_password:
[smtp.gmail.com]:587 username@gmail.com:password
Update and restart postfix:
sudo postmap /etc/postfix/sasl/sasl_password sudo /etc/init.d/postfix restart
The next project is to get DNS set up somewhere to work around 1&1′s pesky 5-subdomain limit.
Recent Comments