Jump to content

[SOLVED] mail(); "filename" header?


hostfreak

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/74666-solved-mail-filename-header/
Share on other sites

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?

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

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;

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.