I'm sure this normally works where if you set the site address in Settings -> General to be http://www.sitename.com then any non-www urls will be redirected.
It doesn't seem to be working on my site, which is more of an issue as my theme doesn't work unless the www is specified:
In Settings -> General I have both WordPress Address (URL) and Site Address (URL) set to use www.
This post says the redirect should be automatic in later versions of WordPress:
Any help appreciated.