What is the MIME type of .eml files in emails
Asked Answered
V

3

7

I want to attach a MTA report (not delivered bounce mail) to an email, but what is the correct MIME type?

I fetch the full body of the MTA report with

$body = imap_fetchbody($this->Mailbox->stream, $this->header->uid, '', FT_UID);

But what is the correct MIME type for attached .eml files?

Have tried message/rfc822 but when you open the file in Thunderbird the popup windows is empty. Have also tried text/plain but then the attachment is opended as plain text. I want to open the attachment .eml as an email

When you receive a MTA report (not delivered) the bounce mail is always forwarded as an attachment

I want to attach the full MTA report + forwarded bounce mail to a new mail

Vineyard answered 13/1, 2021 at 9:4 Comment(2)
Our (proprietary) mail client at work just sets Content-Type: application/octet-stream; name="xxx.EML" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="xxx.EML", and is able to open the received attachment “as” an email again via double click, though I could not say whether that was not probably due to the registered file ending. What happens when you send yourself a mail in Thunderbird, that you just attached an EML file to - does it work as desired then? If so, check the source code of that mail.Ontario
@CBroe its seems to work with application/octet-stream create an answer :)Vineyard
O
10

Content-Type: application/octet-stream should do the trick.


Our (proprietary) mail client at work just sets Content-Type: application/octet-stream; name="xxx.EML" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="xxx.EML", and is able to open the received attachment “as” an email again via double click. Since that mime type is anything but specific, I suppose it falls back onto the file type handler registered for the .eml suffix on the OS level.

Ontario answered 14/1, 2021 at 7:28 Comment(1)
This doesn't work for Gmail. When you receive an email with an eml attachment of type application/octet-stream, Gmail's web interface refuses to load it.Eijkman
I
13

message/rfc822, "encapsulated message".

(That string is reported as the Type when an .eml file is dropped in React Dropzone. YMMV.)

Impostor answered 19/4, 2022 at 17:12 Comment(4)
That's also what the CLI tool mimetype /path/to/file tells meAerodyne
I wish this is the selected answer. Email clients are just too flexible on this. application/octet-stream is for a generic file with bytes.Dorathydorca
This is the right answerFritillary
When you get a bounce-back email and the original sent email is contained, the mime type of that original email is message/rfc822Cortico
O
10

Content-Type: application/octet-stream should do the trick.


Our (proprietary) mail client at work just sets Content-Type: application/octet-stream; name="xxx.EML" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="xxx.EML", and is able to open the received attachment “as” an email again via double click. Since that mime type is anything but specific, I suppose it falls back onto the file type handler registered for the .eml suffix on the OS level.

Ontario answered 14/1, 2021 at 7:28 Comment(1)
This doesn't work for Gmail. When you receive an email with an eml attachment of type application/octet-stream, Gmail's web interface refuses to load it.Eijkman
A
1

There is no mime type for it based on list as of 2020-12-23. See:

http://www.iana.org/assignments/media-types/media-types.xhtml

Argos answered 13/1, 2021 at 9:36 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.