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

Missing attachment when email is not multipart and only contains an attachment #2727

Open
arthurzenika opened this issue Dec 20, 2023 · 18 comments
Labels

Comments

@arthurzenika
Copy link

Describe the bug

When an email has no text or html content and is not multipart and only contains an attachment, postal doesn't show the attachment in the webUI.

To Reproduce

  1. Send the attached email
  2. Click on incoming messages, choose the email
  3. Click on Attachments
  4. See "There are no attachments for this message."

Expected behaviour

For the attachment to be displayed and downloadable in the webUI

Environment details

  • OS: n/a
  • Browser n/a
  • Version : 2.1.4
  • Type : n/a

Additional information/context

postal_example.eml.gz

@arthurzenika
Copy link
Author

Oh and for some context at first we though the bug was #1624

@willpower232
Copy link
Collaborator

I presume you're sending this message with SMTP and not the API? And also that the message arrives at its destination okay with the attachment intact?

@arthurzenika
Copy link
Author

Indeed the message is an incoming email into postal that should then trigger an HTTP endpoint that forwards the mails to our application. To the best of my knowledge, the message does not include the attachment in the HTTP endpoint json call.

(oh and happy new year by the way !)

@willpower232
Copy link
Collaborator

Haha happy new year indeed!

Whatever sends the message with Amazon SES to Postal doesn't construct it with parts, Postal won't identify the attachment at all. Even the scanners I've seen use message parts, are you constructing this message yourself or do you have another device involved?

@arthurzenika
Copy link
Author

I was indeed surprised to see the absence of parts in the email. The email is generated by a company that sends it to our company, we're looking into the possibility of ask them to change the way it is generated. But some mail clients seems to think the email is valid, I haven't found a tool that says the email is invalid.

@willpower232
Copy link
Collaborator

Yeah its definitely Postal being very strict in this context but I'm not sure how extensive the changes would need to be in order to parse it.

I can't immediately see where the attachments are parsed out in either lib/postal/smtp_server/client.rb or lib/postal/message_db/database.rb or lib/postal/message_db/message.rb

@catphish
Copy link
Contributor

This is definitely a bug. I never thought to look for attachments in a non-multipart email. I will see if we can fix it.

@deefdragon
Copy link

As a note, Ive encountered this before from gmail DMARC report emails. They also only send the attachment with the report, and no body text/html. I was hoping to use postal to assist in parsing and reporting of these DMARC emails, as opposed to grabbing the data by hand, but with this bug, its not yet possible.

@Laaknor
Copy link

Laaknor commented Jul 1, 2024

I've been testing with DMARC-reports the last few days, and it was working, until today, when it suddently stoped working for mimecast.org and google.com.

In postal headers, it says "attachment; filename=google.com!!1719619200!1719705599.zip", and if I download the mail, it has an attachment, but when it reaches the HTTP-endpoint, it does not have an attachment, but the size of the request indicates there is an attachment there.

image
image
image

@sinnbeck
Copy link

@Laaknor I just ran into the exact same issue. Did you manage to find a workaround ?

@Laaknor
Copy link

Laaknor commented Aug 28, 2024

@Laaknor I just ran into the exact same issue. Did you manage to find a workaround ?

No, I have temporary changed my DMARC-handling to another solution with a shared mailbox.

@arthurzenika
Copy link
Author

@sinnbeck our work around was to ask for the sender to change the message, so not really, sorry.

@sinnbeck
Copy link

@Laaknor Ah too bad. I might try setting it up with mailgun instead then. At least until a fix is made down the line :) Thanks!

@arthurzenika Sadly it is dmarc emails from google and has the issue, so I don't think I can ask them to fix it :(

@deefdragon
Copy link

deefdragon commented Aug 28, 2024

This is one of the bugs I have offered (offer still stands btw) to sponsor getting fixed, but I have received no communication on actually doing so after the offer in the discord. I'm also not sure the best way to go about it.

@sinnbeck
Copy link

@deefdragon Sad to hear that. I wish I had the understanding to make a pr myself, but sadly I know nothing about mail parsing :/

@sinnbeck
Copy link

I want to see if I can find a workaround for this, but I am unable to recreate the issue when sending an email myself. Does anyone know of a way to trigger the bug from a mail client (outlook, gmail etc) ?

@sinnbeck
Copy link

I believe I have found a work around. Instead of letting postal parse the email, I just send the raw message to my server as form data, and then use a mime parser there to extract the attachment. In testing it worked like a charm. I will report back if there are any issues down the line :)

@sinnbeck
Copy link

sinnbeck commented Sep 2, 2024

I have been running it for 4 days now and everything seems to be working as expected :) 30 reports so far and several of them from google.

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

No branches or pull requests

6 participants