Postfix – Replace Sender Address and Add Reply-to Header

We have a network in which a bunch of servers send out lots of notification emails and all these emails are relayed to the outside world through a single Postifx server (by setting relayhost variable in main.cf on the servers). Sometimes developers don’t pay enough attention and address the emails as from some domain that is not of our network, and such emails tend to be classified as spam by the receivers’ email provider.

Continue reading Postfix – Replace Sender Address and Add Reply-to Header

Setting Up OpenVPN Server in Fedora 14

There are many articles if you Google for “OpenVPN setup”. Most of them teach you how to install OpenVPN on various operating systems and how to write server configuration files. But while some people are looking for solutions of getting into a LAN (in an office, for example) from outside, I think many are seeking a way of breaking through some network restrictions, or creating a secure tunnel to reach the Internet.

In the latter scenario, just getting OpenVPN daemon up running isn’t enough. What we need to do next is setting up IP traffic forwarding and set iptables rules to accept the traffic. Actually my favourate tutorial is this one:

Continue reading Setting Up OpenVPN Server in Fedora 14

Bash doesn’t wrap long lines (linode, CentOS)

I got a VPS from linode one month ago and selected CentOS as the operating system.

I was pretty happy with it but soon found that if the command is longer than the window width, bash doesn’t wrap the line. I compared every possible configuration I could think out with my local CentOS installations but all are identical. When typing a very long command, it shows the command in one line, with the left side truncated, showing only a “>” character instead.

At last I was reminded by someone in the forum that the linode CentOS ships an empty /etc/termcap file. Yes. Reinstalling termcap package solved my problem.

Of course you need to “force” removing the package first:

# rpm -e –nodeps termcap
# yum install termcap

Ad:

In case you want a VPS of your own, I strongly recommend linode. They’re doing very great. You get control of everything and there’s an easy-to-use dashboard (even api). Up/down-grading can be done effortlessly.

If you’re interested, you can consider using my referral URL (thanks a lot :-)):

http://www.linode.com/?r=e79251a33caf24fa1cf09c860deb2a6042999c52

Deleting the MT-powered blog

Months ago, I started a blog about interesting advertisements powered by Movable Type. During the installation and usage process, I got some knowledge about Movable Type, but the fact is that I’m still not quite familiar with it. Besides, the chosen topic is not quite related to my daily life. So now I’m stopping and deleting the blog.

Movable Type is a great blogging platform, and the team has been inventing many techniques and concepts, but the problem is that it’s defeated by WordPress because it’s not as simple and WordPress now has much more plugins.

The only advantage of using MT is that you don’t need to worry about the server load (digg effect, for example), but this is not a problem for us “little” bloggers. After several weeks, I even didn’t remember the url of the administration area.

I may start another blog, powered by WordPress, of course :)

500 Error During Movable Type Installation

I followed the official instructions to install Movable Type 4 on this host, but the 500 error page appeared every time I clicked the “begin” button. Besides, the mt-check.cgi script generated an incomplete HTML output – it’s terminated at some point.

The log of the 500 error:

… Out of memory!, referer: http://example.com/cgi-bin/mt/mt-wizard.cgi
… Callback called exit at mt-wizard.cgi line 11., referer: http://example.com/cgi-bin/mt/mt-wizard.cgi
… END failed–call queue aborted at mt-wizard.cgi line 1., referer: http://example.com/cgi-bin/mt/mt-wizard.cgi
… Callback called exit at mt-wizard.cgi line 1., referer: http://example.com/cgi-bin/mt/mt-wizard.cgi
… BEGIN failed–compilation aborted at mt-wizard.cgi line 11., referer: http://example.com/cgi-bin/mt/mt-wizard.cgi
… Premature end of script headers: mt-wizard.cgi, referer: http://example.com/cgi-bin/mt/mt-wizard.cgi

I read through the troubleshooting doc of Movable Type but it seems not to be any of the problems listed there. When I searched for “Premature end of script headers: mt-wizard.cgi“, there’re no answers in English results.

I asked the support of this hosting company but at first they said it must be the problem of the script. Oh I’m using the stable release of MT4 and it’s used widely across the world. I wouldn’t believe it.

Then suddenly I received a message from root in the secure shell:

Please try to do your installation again.
We have identified a problem which has been corrected.

Yes, it worked like a charm. Soon I received a the problem description from support:

The problem appears to be related to memory limitation set in the apache configuration. This Apache limitation has been removed and memory is now controlled via PHP.

There’re quite a lot people stuck by this error when trying to start the Movable Type tour as I see. Most people don’t believe that the memory out error is true but indeed it is in my case. Hope this helps someone.

Small Flaw of Digg Podcasts

Digg Podcast

Now Digg is beta testing its “Podcasts” section. There is a module on the right of the page, with two tabs, “Find Podcast” and “Add New Podcast”.

Open the page and try clicking the tabs. You will discover the weird behaviors of this module.

Digg is using this single JavaScript function to handle the click events of the two tabs (Note that Prototype framework is used.):

function pcSwitchTabs(){
  var tab1 = $('podcastFind');
  var tab2 = $('podcastAdd');
  var addbox = $('podcast-add-box');
  var errordisplay = $('podcast-error-display');
  var ad = $('podcast_ad_switch');
  var psearch = $('podcast-search');
  var psubmit = $('podcast-submit');
  if (tab1.className == 'active') {
    tab1.className = '';
    tab2.className = 'active';
    if (addbox) {
      addbox.style.display = 'block';
    }
  }
}

You should ignore several lines of unused code. What does this function do? As its name, it switches the tabs back and forth. And it’s called either of the tabs is clicked. So the weird thing happens – whichever tab you click on, the current tab changes. This can make users very confused.

Another thing is that when you click on a tab, the page scrolls back to the top after the tab switch. This will definitely make users lose their attention. The code for the click-able tab:

<a onclick="pcSwitchTabs()" href="#">Find Podcast</a>

After executing the onclick event handler code, the browser tries to open the link specified by the “href” attribute. A “#” makes the page scroll back to the top. There are some common solutions to this. For example, give href attribute a value of “javascript:void(0)” or append “return false” to onclick attribute to stop the event.

These two bugs are very easy to fix, but leaving them aside will definitely make users confused or unhappy. I don’t know how the beta process is going, but hope Digg will fix them one day.