hostfreak Posted October 25, 2007 Share Posted October 25, 2007 What header is used the set the filename? Right now, when sending an html email, the attached file is named "unnamed". Here are the headers I am currently using: //Headers $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ' . $email; I did a brief google search which did return results, but piecing it together didn't work out so well. Thanks in advanced. Quote Link to comment https://forums.phpfreaks.com/topic/74666-solved-mail-filename-header/ Share on other sites More sharing options...
Michan Posted October 25, 2007 Share Posted October 25, 2007 And related: How does this function send a rich HTML email? A <BR /> and <a href></a> in an email would be oh-so-useful. Quote Link to comment https://forums.phpfreaks.com/topic/74666-solved-mail-filename-header/#findComment-377430 Share on other sites More sharing options...
MadTechie Posted October 25, 2007 Share Posted October 25, 2007 $body .= "Content-Type:".OCTET."; name=\"$file\"".CRLF; $body .= "Content-Transfer-Encoding: base64".CRLF.CRLF; $body .= "Content-Disposition: attachment; filename=\"$file\"".CRLF.CRLF; Quote Link to comment https://forums.phpfreaks.com/topic/74666-solved-mail-filename-header/#findComment-377436 Share on other sites More sharing options...
hostfreak Posted October 25, 2007 Author Share Posted October 25, 2007 MadTechie, thanks for the reply. If you don't mind, can you explain to me the meaning of the headers your using? For example, the Content-Type: "OCTET". Also, the "CRLF". And what is the reason for the "Content-Transfer-Encoding" header? The rest I am pretty sure I understand. Thanks. Edit: Also, I am assuming your code (based on the $body) should be apart of the message parameter? Not the additional headers? Quote Link to comment https://forums.phpfreaks.com/topic/74666-solved-mail-filename-header/#findComment-377439 Share on other sites More sharing options...
MadTechie Posted October 25, 2007 Share Posted October 25, 2007 Okay.. Multiple extra headers should be separated with a CRLF (\r\n). Encoding should be base64 if your attacking a file i encode it ie <?php $fp = fopen($file,"rb"); $fcontent = fread($fp ,filesize($file)); fclose($fp); $content = chunk_split(base64_encode($fcontent)); ?> as for the OCTET.. well the data may not be text only, so octet works better.. I think i covered them all!! let me know what doesn't make sense Quote Link to comment https://forums.phpfreaks.com/topic/74666-solved-mail-filename-header/#findComment-377445 Share on other sites More sharing options...
hostfreak Posted October 25, 2007 Author Share Posted October 25, 2007 Ah I see. Makes perfect sense. Thanks. Edit: Does it make a difference whether someone uses "CRLF" or \r\n? And what is OCTET an abbreviation for? Edit: Sry, One more. What is the point of the multiple ".CRLF.CRLF" on: $body .= "Content-Disposition: attachment; filename=\"$file\"".CRLF.CRLF; Quote Link to comment https://forums.phpfreaks.com/topic/74666-solved-mail-filename-header/#findComment-377450 Share on other sites More sharing options...
MadTechie Posted October 25, 2007 Share Posted October 25, 2007 CR = \r LF = \n i just defind CRLF as "\r\n" the reason i double it, is mainly because it seam to work better on more mail servers.. an octet is the name of the group of 8 bits that make up 1 byte.. from the Octal number base.. i don't think i have even said that outside of a computer science class! anyways its defind from "octet-stream" but you could use multipart/related.. its all down the file type your using.. "octet-stream" seams to work on 99% of them Quote Link to comment https://forums.phpfreaks.com/topic/74666-solved-mail-filename-header/#findComment-377462 Share on other sites More sharing options...
hostfreak Posted October 25, 2007 Author Share Posted October 25, 2007 Everything (pertaining to my questions) makes sense now. Thanks for the clarification(s) MadTechie! Quote Link to comment https://forums.phpfreaks.com/topic/74666-solved-mail-filename-header/#findComment-377479 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.