At 14:31 10.11.2002, Oliver Witt said:
--------------------[snip]--------------------
>I wrote a php script that's supposed to enable me to attach files to an
>email. However, the attached files ends up being a mess of letters.
>"Hallo" becomes "SGFsbG8=". That must have to do with encoding. Is that
>a common problem or do you need the entire script?
--------------------[snip]--------------------
It seems that you're encoding the file somehow - that's usual, even
required if your file is a binary file (like a picture, or a formatted
document).
In your mail headers, you should see some MIME like
Content-Type: multipart/alternative;
boundary=GU4wuTSk68F
("alternative" could also read "related" - depends on the content, the
"multipart" is the point here)
which would tell the client browser that the next mail consists of a couple
of separate parts, with a separator line as "--GU4wuTSk68F".
Next comes the message entity, which starts with such a separator line, and
a set of MIME headers for the respective entity:
--GU4wuTSk68F
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
Content-Type: text/plain
You are receiving this message as a subscriber
to the Just For You Network. To cancel, see the
instructions at the end of this mail.
That's the first part of the mail - it's plain text. The next part would be
an image, and again starts with a boundary:
--GU4wuTSk68F
Content-Type: image/jpeg;
name="sample.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="sample.jpg"
JVBERi0xLjMNJeLjz9MNCjE5OSAwIG9iag08PCANL0xpbmVhcml6ZWQgMSANL08gMjAy
JVBERi0xLjMNJeLjz9MNCjE5OSAwIG9iag08PCANL0xpbmVhcml6ZWQgMSANL08gMjAyIA0vSCBb
IDE2NDUgMjc0IF0gDS9MIDEwOTMzMSANL0UgNzg3MDYgDS9OIDMgDS9UIDEwNTIzMiAN
IDE2NDUgMjc0IF0gDS9MIDEwOTMzMSANL0UgNzg3MDYgDS9OIDMgDS9UIDEwNTIzMiANPj4gDWVu
[...]
RHA0NjcxUFJGbzgtMTZsNDM=
--GU4wuTSk68F
The message should also end with a boundary, but most mail client's omit
this...
For more information consult RFC2045 ff about MIME
ftp://ftp.rfc-editor.org/in-notes/rfc2045.txt
Hope this helps,
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php