Great tutorial/article about controlling a relay from the Pi. It’s quite an old post (from June 2012) but it does mean that there are loads of comments at the bottom of the post with more information. If you’re interesting in controlling mains voltage from the Pi, have a read!