You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been parsing emails from from Outlook (I think), and I've seen that the attachment parts have no filename information:
# ... earlier parts of email
--_001_ABC123MAILPARTDIVIDERRANDOMNUMBERS_
Content-Type: message/rfc822
Content-Disposition: attachment;
creation-date="Tue, 03 Dec 2024 12:01:37 GMT";
modification-date="Tue, 03 Dec 2024 12:01:37 GMT"
From: Alice Smith <[email protected]>
To: "Bob" <[email protected]>
Subject: Some email file I'm attaching
# etc ...
The Mail gem fails to recognise this as an attachment, despite the content disposition, because there's nothing it recognises as the filename, and that's fundamental to how Mail determines if an attachment exists.
According to the RCF, the filename is not mandatory, and I believe the intention that mail implementations can use the value, if present, but also aren't obliged to.
In my particular case, I'd like to be able to get all parts that have Content-Disposition: attachment as attachments, and I am not sure it's technically correct that our gem only reports parts that have filenames. I would be happy to supply a default filename; perhaps message.attachments would expose the nameless attachment's mime type to me and let me use something like Marcel to determine an appropriate file extension.
I'd be more than happy to work on a PR; I have a patch in my app for the particular case I'm hitting, but if we can figure out a general approach that works for all unnamed attachment types, I'd be more than happy to put the work in to address it.
The text was updated successfully, but these errors were encountered:
Unfortunately #1389 doesn't fix this specific issue (although it fixes others, and I'm using the patch in our app, thank you!). This issue only occurs when the mail part has none of the header information that Mail tries to use as the filename specifically.
I've been parsing emails from from Outlook (I think), and I've seen that the attachment parts have no filename information:
The Mail gem fails to recognise this as an attachment, despite the content disposition, because there's nothing it recognises as the filename, and that's fundamental to how Mail determines if an attachment exists.
According to the RCF, the filename is not mandatory, and I believe the intention that mail implementations can use the value, if present, but also aren't obliged to.
In my particular case, I'd like to be able to get all parts that have
Content-Disposition: attachment
as attachments, and I am not sure it's technically correct that our gem only reports parts that have filenames. I would be happy to supply a default filename; perhapsmessage.attachments
would expose the nameless attachment's mime type to me and let me use something like Marcel to determine an appropriate file extension.I'd be more than happy to work on a PR; I have a patch in my app for the particular case I'm hitting, but if we can figure out a general approach that works for all unnamed attachment types, I'd be more than happy to put the work in to address it.
The text was updated successfully, but these errors were encountered: