homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Email Attachment Problem

 11:55 am on Apr 27, 2011 (gmt 0)

I am using a popular email script that provides for file attachments. My problem, the attached files are always received as .txt no matter what type is actually sent.

i.e. when sample.jpg is attached the file received would be something like this ATT00037.TXT not the original jpg as expected.

Perhaps someone can get me pointed in the right direction.



 2:58 pm on Apr 27, 2011 (gmt 0)

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!


 3:17 pm on Apr 27, 2011 (gmt 0)

Yes what I thought so I tried a different script and it is the same thing....

I have peeked at the code and the scripts are certainly parsing for file type and setting the correct MIME type.

Perhaps there is a server setting that is the issue?


 3:49 pm on Apr 27, 2011 (gmt 0)

The fix:


instead of:


I wish I understood what was actually going on with the new lines and their effect on attachments!


 3:39 pm on Apr 28, 2011 (gmt 0)

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:


Clicking the top result:

404 :(

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved