Skip to content

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

Open
@lazyatom

Description

@lazyatom

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions