Welcome to WebmasterWorld Guest from 54.147.220.66

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Email Attachment Problem

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

WebmasterWorld Senior Member 10+ Year Member



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)

WebmasterWorld Senior Member 10+ Year Member



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)

WebmasterWorld Senior Member 10+ Year Member



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)

WebmasterWorld Senior Member 10+ Year Member



The fix:

define("HEAD_CRLF","\n");
define("BODY_LF","\n");

instead of:

define("HEAD_CRLF","\r\n");
define("BODY_LF","\r\n");

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)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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:

[zend.com...]

Clicking the top result:
[zend.com...]

404 :(