Title: Sending MIME emails with base64 encoded attachments

Hello there

My base64 encoded attachments in MIME emails come corrupted.

I using PHP4 on SuSe Linux.
I'm sending an MIME email (I generatate all the headers and so on) with attachments.
The first part is7bit text, 2nd part is mime-type I get from file and encoding: base64
The file I need to attach I read from disc using $txt=fread($file,filesize($filename)); the file is opened
by $file=fopen($filename,"r").
Then I encode the content with:
and split it with:

When I then send it, the mail arrives, but the attached file (e.g. *.zip) is corrupted.
Attachment is a little bit larger than original.
In original there are #0 (char. ascii 0), in attachment they come as "\0" (#92#48).

Attachments like text files (even with characters behind #127) are OK, they come without any corruption.

I tried to write small test.php, where I just load file, base64_encode it and then base64_decode it, and it's OK.

Seems to me that PHP use "another" base64 coding than all email clients
The way how I read the file is bad, so base64_encode gets a little different data, but is still able to get it back on the local

I don't know :-(

Please, help, if you can.

Many thanks

Petr Svarc

This electronic message transmission contains information from TMP Worldwide
and is confidential or privileged.  The information is intended to be for the use of
the individual or entity named above. If you are not the intended recipient, 
be aware that any disclosure, copying, distribution, or use of the contents of this
information is prohibited. If you have received this electronic transmission in error,
please notify us by telephone immediately at +44 (0)20 7406 3333

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to