Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing mail with attachment that has no filename will not find attachment #1627

Open
lazyatom opened this issue Dec 5, 2024 · 4 comments · May be fixed by #1628
Open

Parsing mail with attachment that has no filename will not find attachment #1627

lazyatom opened this issue Dec 5, 2024 · 4 comments · May be fixed by #1628

Comments

@lazyatom
Copy link

lazyatom commented Dec 5, 2024

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.

@ahorek
Copy link
Contributor

ahorek commented Dec 17, 2024

could you check if #1389 fixes the issue? the change hasn't been released yet.

@lazyatom
Copy link
Author

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.

@ahorek ahorek linked a pull request Dec 17, 2024 that will close this issue
@ahorek
Copy link
Contributor

ahorek commented Dec 17, 2024

ok, try this #1628

however, I'm not sure if it handles all real cases...

@lazyatom
Copy link
Author

That works for my test case, certainly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants