There could be a number of reasons it's not working.
First of all, is your SQL working? You are using $theusername -- is it set correctly? If not, and it's coming from a previous form, then register_globals is probably OFF, and you need to use $_POST['theusername'].
If that's not the problem, then echo your variables to the screen to make sure they are being set properly. If not, then there is your problem, and you can investigate.
Lastly, does the mail() command work if you hard code values into it? If not, then you have an issue with your mail server.
As far as your code goes, it seems ok, but I question the To: header. I don't think it's necessary, since you are using $emailaddress to specify the recipient. Try commenting out that line.
Hope this helps. Good Luck!