Which MIME type to use for a binary file that’s specific to my program?

I’d recommend application/octet-stream as RFC2046 says “The “octet-stream” subtype is used to indicate that a body contains arbitrary binary data” and “The recommended action for an implementation that receives an “application/octet-stream” entity is to simply offer to put the data in a file[…]”. I think that way you will get better handling from arbitrary programs, … Read more

How to use the CSV MIME-type?

You could try to force the browser to open a “Save As…” dialog by doing something like: header(‘Content-type: text/csv’); header(‘Content-disposition: attachment;filename=MyVerySpecial.csv’); echo “cell 1, cell 2”; Which should work across most major browsers.

Register file extensions / mime types in Linux

Use xdg-utils from freedesktop.org Portland. Register the icon for the MIME type: xdg-icon-resource install –context mimetypes –size 48 myicon-file-type.png x-application-mytype Create a configuration file (freedesktop Shared MIME documentation): <?xml version=”1.0″?> <mime-info xmlns=”http://www.freedesktop.org/standards/shared-mime-info”> <mime-type type=”application/x-mytype”> <comment>A witty comment</comment> <comment xml:lang=”it”>Uno Commento</comment> <glob pattern=”*.myapp”/> </mime-type> </mime-info> Install the configuration file: xdg-mime install mytype-mime.xml This gets your files … Read more

How to read text inside body of mail using javax.mail

This answer extends yurin’s answer. The issue he brought up was that the content of a MimeMultipart may itself be another MimeMultipart. The getTextFromMimeMultipart() method below recurses in such cases on the content until the message body has been fully parsed. private String getTextFromMessage(Message message) throws MessagingException, IOException { String result = “”; if (message.isMimeType(“text/plain”)) … Read more

What rules apply to MIME boundary?

The syntax of a boundary is: boundary := 0*69<bchars> bcharsnospace bchars := bcharsnospace / ” ” bcharsnospace := DIGIT / ALPHA / “‘” / “(” / “)” / “+” / “_” / “,” / “-” / “.” / “/” / “:” / “=” / “?” And the body of a multipart entity has the syntax … Read more