I have an e-mail client written in C++. I wrote it some years ago, using plain SMTP messages through sockets.
Now I have to attach some PDF files to the message, so I learned all about the MIME thing. It works fine with text files, but I have problems with PDF files.
This are the headers I put on my message:
Content-Type: application/octet-stream; name=xx.pdf
Content-Disposition: attachment; filename=xx.pdf
Next I read the xx.pdf file using fread and send it through the socket.
The message goes to the server and is received by the recipient ok.
When the recipient opens the file (with Acrobat Reader) the file is corrupt. Before each byte with value 0A, "someone" inserted an extra byte with value 0D.
I think the problem is on the message headers, but I can't figure it out.