It sounds like your script doesn't set the MIME Type of the attached file properly. You could scan the code for instances of "text/plain" or "text/html" and create a patch that would set the MIME Type correctly based on the file type of the attachment. But my advice would be to find another script that sends attachments properly. The web is full of them. Ultimately, that will be the simplest and most reliable solution. Good luck!
To understand you will either need to read the RFC on Mail MIME and/or peel apart an existing script, perhaps the PEAR Mail MIME package. Both can be found on the PHP manual page for the mail [php.net] function.
John Coggeshall once had a well-written tutorial/article on mail attachments but I am having a tough time locating it now. All the old links to Zend on this forum are coming up 404 now so Zend must have removed them after John left. The actual article comes up on Zend's search engine but then offers you a 404 on their own site search: