Re: attachement
| From: | Oliver Witt | Date: | Sun, 10 Nov 2002 14:51:38 +0000 |
| Subject: | Re: attachement | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123692@lists.php.net to get a copy of this message | ||
Ernest E Vogelsinger schrieb:
> At 15:27 10.11.2002, Oliver Witt said:
> --------------------[snip]--------------------
> >I had it set like this:
> >
> >$fp = fopen($file, "r");
> >$contents = fread($fp, $file_size);
> >$encoded_file = chunk_split(base64_encode($contents));
> >fclose($fp);
> >
> > ...
> >
> >$body.= "\n\n--Message-Boundary\n";
> >$body.= "Content-type: $file_type; name=\"$file_name\"\n";
> >$body.= "Content-Transfer-Encoding: PLAINTEXT\n";
> >$body.= "Content-disposition: attachment; filename=\"$file_name\"\n\n";
> >$body.= "$encoded_file\n";
> >$body.= "--Message-Boundary--\n";
> --------------------[snip]--------------------
>
> You must not give PLAINTEXT as encoding when you have it base64... use:
> Content-Transfer-Encoding: base64
>
> BTW, "PLAINTEXT" is not a MIME recognized encoding type. Excerpt from RFC2045:
>
> --------------------[snip]--------------------
> 5.2. Content-Type Defaults
> Default RFC 822 messages without a MIME Content-Type header are taken
> by this protocol to be plain text in the US-ASCII character set,
> which can be explicitly specified as:
>
> Content-type: text/plain; charset=us-ascii
>
> This default is assumed if no Content-Type header field is specified.
> It is also recommend that this default be assumed when a
> syntactically invalid Content-Type header field is encountered. In
> the presence of a MIME-Version header field and the absence of any
> Content-Type header field, a receiving User Agent can also assume
> that plain US-ASCII text was the sender's intent. Plain US-ASCII
> text may still be assumed in the absence of a MIME-Version or the
> presence of an syntactically invalid Content-Type header field, but
> the sender's intent might have been otherwise.
>
> 6.1. Content-Transfer-Encoding Syntax
> The Content-Transfer-Encoding field's value is a single token
> specifying the type of encoding, as enumerated below. Formally:
>
> encoding := "Content-Transfer-Encoding" ":" mechanism
>
> mechanism := "7bit" / "8bit" / "binary" /
> "quoted-printable" / "base64" /
> ietf-token / x-token
>
> These values are not case sensitive -- Base64 and BASE64 and bAsE64
> are all equivalent. An encoding type of 7BIT requires that the body
> is already in a 7bit mail-ready representation. This is the default
> value -- that is, "Content-Transfer-Encoding: 7BIT" is assumed if the
> Content-Transfer-Encoding header field is not present.
> --------------------[snip]--------------------
>
> Therefore, for plaintext headings you should use
> Content-type: text/plain
> Content-Transfer-Encoding: 7bit (or 8bit, depends)
>
> --
> >O Ernest E. Vogelsinger
> (\) ICQ #13394035
> ^ http://www.vogelsinger.at/
thanks you very much, that's it, it's working perfectly now!!!
thx, Olli