2 things...
-
I don't see where you are sending the status code back to the browser (302 in this case, I believe)
However, since you say it is sending the .pl file back to the user, it sounds like your server is not running the .pl file (shouldn't that be .cgi?), but is treating it as a binary file. What are the contents of the file it is asking you to download? See the posts by trwww below.
Now a few warnings:
- Your code is not sanitizing the data from the user at all. In fact, it would be trivial to implement a code injection attach against this script. What happens if $message, $subject, $raddr, or $saddr contain quotes, extra parameters, or even extra commands?
- You are using the one parameter form of system. Use the multiple parameter form of system instead. That can help mitigate the risk of only part of the previous security question.
Not to be harsh, but this script has gaping holes reminiscent of Matt's Script Archive and large enough for Santa Clause to drive his sleigh through. Please consider finding an application from NMS or other recommended sites that meets your needs.