Saturday, February 17, 2007

Configuring Postfix to forward emails for multiple domains to local mailbox

A friend was recently looking to configure postfix, so that he could send emails from his laptop to several domains and have all of them show up in his local mailbox. I'm posting the simple configuration for postfix that helps make this happen.

  1. Check your postfix configuration. If you don't already have postfix, you can get it here. The instructions below all assume you have a Unix OS and shell. I did the below on a Mac OS X as well as a Sun OS host. I am sure it almost identical on most Unix environments.
    • Check that you have the postfix executable installed. (Usually in /usr/sbin/postfix)
    • Check that the configuration directory and files exist. (/etc/postfix/main.cf)
    • Ensure you have the access to edit the configuration files and create files in the postfix configuration directory. You will also need to restart postfix.
2. Edit the /etc/postfix/main.cf file. Add these lines at the end: (double check to make sure your spellings are correct. :)

# Testing virtual host domains
virtual_alias_domains = testdomain1.com testdomain2.com
virtual_alias_maps = hash:/etc/postfix/virtual


3. Edit /etc/postfix/virtual, and and these lines: (Replace recipient by any Unix user account you want to receive emails on your machine).

@testdomain1.com recipient
@testdomain2.com recipient


4. In the directory /etc/postfix, run the following command. This creates the hash database file needed by postfix for virtual alias table.

$> postmap hash:virtual


5. This above command would have created the file virtual.db in this directory. Verify.

6. Restart postfix. In case postfix is not running, you use "postfix start" to get it going.



$> sudo postfix reload
postfix/postfix-script: refreshing the Postfix mail system
$>


7. Test: (the user running the second command is the user whose account emails are being forwarded to, as per the settings in step 2 above).



$> mail -s "test mail" anyuser@testdomain1.com < /dev/null
Null message body; hope that's ok
$> mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/mail/vikasgupta": 1 message 1 unread
>U 1 vikasgupta@localhost Thu Feb 15 11:33 16/505 "test mail"
$>


Postfix comes with plenty of documentation on how to configure and use it. For more details on the above configuration, look at the VIRTUAL_README in the postfix distribution. The utility postconf is useful to review the configuration once you've reloaded it into postfix.

Saturday, February 10, 2007

Whither India?

Debate's raging, it seems, on India's contention for the "next superpower." There's a CNN article that naysays it pretty loudly. Of course, if you are in India you can hardly escape the constant bombardment of the opposite.

India's contending for a permanent seat in the Security Council. India's sustained a growth rate of 8% year over year for four straight years. If you believe the economists in India, the country can sustain this growth forever more. Last Economist issue stressed the need for investment in infrastructure for India to be able to sustain this growth.

I spent a significant part of the last two years in India. I was based in Bangalore. I travelled through Mumbai, Chennai, Delhi, Pune. Being in Bangalore, it is impossible to get away from the constant buzz. Salaries jump at a phenomenal rate every year -- for the software/IT industry at least. We were desperately seeking engineers, and so was everyone else. In the end, it was hard to find talented engineers with significant experience, and still harder to hire them and nearly impossible to keep them happy.

Of course, it is tough to stay happy in a place like Bangalore. There are parts of Bangalore you may visit that remind you why this ruckus started in the first place -- the campus of IISc comes to mind. I recall one funny incident that highlighted what a mess this place has become.

I had landed at the Bangalore airport, and was taking the office taxi home. In order to get to my house, the taxi had to go through the central business district. No to say, the airport road itself -- that probably packs more vehicles per square inch than anywhere else in the world.

When I told the driver where I needed to go, he simply said, "No sir. We won't go there." Huh? I told him, gently, that I need to go there and he has to take me there. "No sir. We'll go somewhere else. Too much traffic, sir. Where do you want to go sir?"

Well, he finally came around, and we inched along.

The moral of the story is -- infrastructure in Bangalore, and many other places in India -- needs serious investment. It is improving, but not it's not keeping pace with the growth. In places like Bangalore, it is crumbling.

Superpower? Whatever. The term itself seems to be a leftover from the 80s.

Rails

I posted a couple of handy techniques for Rails here.

Anthony Lane is raving about the German movie "Lives of Others." It's yet to make it out to SFO, though. Economist recently carried an article about the resurgence of German cinema, and it makes references to Lives of Others as well.