Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting wrong contentType from EML attachment

I am using Microsoft Graph to fetch mail and I recently noticed when an email has a .eml attachment, there are two cases:

  1. If the sender attach that email through drugging emails to the composer, the attachment will be an item attachment type. <-- I can handle this case

  2. If the sender attaches a .eml file through clicking "attach file", that attachment will be a type of file attachment. Up to this point, I think it is fine to be a file attachment. But when I try to fetch that attachment, the attachment content type is application/octet-stream which is wrong. Shouldn't it be message/rfc822? With application/octet-stream, I cannot create that attachment from our server.

like image 976
CipherText Avatar asked Dec 09 '25 19:12

CipherText


1 Answers

It isn't wrong, application/octet-stream simply represents a generic/unknown binary file. From RFC 2046 § 4.5.1:

The "octet-stream" subtype is used to indicate that a body contains arbitrary binary data.

Your application can make its own determination on how to handle the file. In this case, the .eml is just a text file. You can simply fetch the attachment and treat it as raw text.

like image 180
Marc LaFleur Avatar answered Dec 11 '25 21:12

Marc LaFleur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!