A number of years ago, when GMAIL was just starting to get popular; there was privacy controversy over the fact that Google was scanning the contents of your emails in order to show contextual ads. Just as the tech press was starting to go ballistic over this story, I was making the decision about where to host email for personal domains.
There were two options
- Build my own email server
- Use a hosted service.
- At this time, given my list of requirements, GMAIL was the only option.
Using GMAIL was and still is the obvious answer. Google runs a mail service so much better than I can. And all the time I would spend installing patches and figuring out why SPAM is getting through, for example, could be spent doing better things like skiing or spending quality time in a hammock in my backyard.
In my head I understood that GMAIL was the way to go, but I could not shake the feeling that running my own server was the best and only option. Looking back I realize the reasons for this were:
- I wanted to own my email messages. I wanted to make sure I could access messages from yesterday, from 1 year ago and from 15 years ago. They are mine and I do not want a company or government take-down order to block my access to them.
- (This one is a bit irrational(as email is like a postcard, anyone can read it at any point in the journey)) By hosting my own email server, I could make sure there was one less large corporation reading my email.
As you could guess, I ended up building and running my own email server. It started out at Slicehost and it now resides over at Rackspace Cloud.
With the decision to run a blog at http://www.fourproc.com, I needed to add a few more domains to this email server. In order to do this I had to enable Virtual Hosting support in sendmail. This is surprisingly easy to do.
Add Virtual Hosting support in sendmail
Enable virtusertable feature
Virtusertable is essentially an alias file. It allows you to route incoming email addresses from multiple domains to the appropriate mailbox. (See the virtusertable section at http://www.sendmail.org/m4/features.html for more information)
Edit the sendmail configuration file
Create and configure the virtusertable file. (Below is a sample file)
# Email addresses for fourproc, 4proc
# Catch-all addresses for each domain
Create the virtusertable db file
makemap -r hash virtusertable.db < virtusertable
This table will route incoming messages in the following way
- Incoming messages to email@example.com will be delivered to brian’s mailbox
- Incoming messages to firstname.lastname@example.org will be delivered to user2-fourproc mailbox
- Incoming messages to email@example.com will be delivered to user2-fourproc mailbox
- Incoming messages to firstname.lastname@example.org will be delivered to user4-fourproc mailbox
- Incoming messages to email@example.com will be delivered to brian’s mailbox
- Incoming messages to any other email address in fourproc.com domain will be delivered to the catchme mailbox
- Incoming messages to any email address in 4proc.com domain will be delivered corresponding user in the fourproc.com domain.
Enable generic_entire_domain feature
The genericstable and generics-domain features control the routing of outgoing email address. If the genericstables and the
GENERICS_DOMAIN_FILE features are enabled, then sendmail will masquerade the from address and the envelope if the FROM addresses domain is in the
GENERICS_DOMAIN_FILE file. (See the genericstable section at http://www.sendmail.org/m4/features.html
Edit the sendmail configuration file
Create and configure the genericstable. (Below is a sample file)
For my case, no entries in the table were needed. Create the generics table db file
makemap -r hash genericstable.db < genericstable
Create and configure the generics-domains file. (Below is a sample file)
Start sendmail using the new configuration
The first thing I need to do is create the new sendmail.cf configuration file
make -C /etc/mail
Now I can restart the sendmail server
That was it. It was pretty simple. Took me a few hours total to research how to do it, test the configurations on a spare AWS instance and rollout to the production server. This was probably 8X longer than it would have taken me to rollout these domains using Google Apps. Maybe sometime in the future, my reasons for running my own email server will no longer matter to me and I will move over to GMAIL or another service. But for now, I am sticking with running my own.