While we're at it, here is some general comments about your code:
- You declare a global in a subroutine. This sort of loose coupling is a big no-no, because it makes subtle bugs, and makes code more confusing. Consider returning the hash
- You then take the %formdata hash and after generating it say my %formdata. Apart from the fact that Globals R Bad, this is a extraneous construct. You can get rid of it.
- As has been mentioned, use a module to handle the sending of mail. It's more complicated than it looks (and it looks complicated). The module will save you the headache.
- There is no need to iterate through each param to build your hash. CGI.pm provides a method which will give you a hash straight off, and thus be more efficient and let you get rid of the sub all together.
- You use strict. Nice. But you also might want to use warnings, and most definately turn on -T for tainting, to ensure that your programs stay secure. You should do this at least for EVERY CGI program you write.
I also just want to say that you've come a long way since your early work you asked everyone in th CB to bugcheck. keep learning.
Cheers,
Erik