0

The MIME type of the attachment is determined from the filename. If a filename is *.csv it is validated for processing. Is there a way to find if file-extension/mimetype is appropriate to the content in file?

sheenu85
  • 168
  • 2
  • 11
  • This is probably duplicate of http://stackoverflow.com/questions/51438/getting-a-files-mime-type-in-java – jdevelop Aug 23 '12 at 07:57

1 Answers1

0

Actually, when receiving mail, attachment types are not determined via filenames, but via Multipart message subtypes. Also see the relevant RFC.

Now, sender can of course lie: *.csv file might not actually contain CSV content. But this is highly content-specific. To check this you would actually need to read the CSV content and check if it's valid. It's not a job of email system or email client to actually check that content is valid.

If you need to check for valid CSV, you should parse it and check the contents. See opencsv.

Peter Knego
  • 79,991
  • 11
  • 123
  • 154