iachat/spec/fixtures/files
Pranav 24f49b9b5a
fix: Process non-image inline attachments as regular attachments (#10998)
In Chatwoot, we rely on the Content-ID for inline attachments to replace
the link with the uploaded attachment URL. Our expectation was that only
images would be inline, while other attachments would not. However,
email clients like Apple Mail (sigh) allow users to send inline
attachments that are not images, and these attachments often lack a
Content-ID. This creates significant issues in rendering.
 
I investigated how other email clients handle this scenario. When
viewing the same email (sent from Apple Mail) in Gmail, only one image
appears—and it’s treated as an attachment, not inline. This happens
because both attachments are the same image, and Apple Mail only sends
one copy. See the screenshot below.

| Apple Mail | Gmail | 
| -- | -- | 
| <img width="646" alt="Screenshot 2025-02-27 at 8 20 17 PM"
src="https://github.com/user-attachments/assets/e0d1cd2d-e47c-4081-a53b-7a67106341b3"
/> | <img width="360" alt="Screenshot 2025-02-27 at 8 20 51 PM"
src="https://github.com/user-attachments/assets/b206e56e-8f86-43e9-867b-d895c36aff78"
/> |

A good fix for this would be to check if the Content-ID is missing and
then upload the file as a regular attachment. However, the Mail gem (for
some reason) automatically adds a default Content-ID to inline parts. I
need to dig into the source code to understand why this happens.

For now, I’ve implemented a check to treat non-image attachments as
regular attachments. Inline image attachments are already handled by
appending an image tag at the end if the content-id is not found in the
body. A sample conversation to test this behavior is
[here](https://app.chatwoot.com/app/accounts/1/conversations/46732).
2025-02-28 13:33:48 -08:00
..
.keep Fix url in emails, add frontendURL helper (#19) 2019-08-25 19:59:28 +05:30
attachments_without_filename.eml fix: Email attachments created with empty filename (#10420) 2024-11-15 09:07:24 +04:00
attachments_without_text.eml fix: Process attachments as regular attachments if the text/plain or text/html part is empty (#10379) 2024-11-04 10:25:01 +01:00
auto_reply_with_auto_submitted.eml chore: Stop processing auto-response emails (#9606) 2024-06-13 14:19:11 -07:00
auto_reply.eml chore: Stop processing auto-response emails (#9606) 2024-06-13 14:19:11 -07:00
bounced_with_no_from.eml chore: Fix sentry errors in email processing for bounce notifications (#8677) 2024-01-10 14:30:23 -08:00
email_with_inline_pdf.eml fix: Process non-image inline attachments as regular attachments (#10998) 2025-02-28 13:33:48 -08:00
forwarder_email.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
group_sender_support.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
html_and_attachments.eml Fix: html mail fix with html_body content (#4011) 2022-03-30 18:04:30 +05:30
in_reply_to.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
mail_with_html_part_no_html_content.eml fix: Update mail check for html_part (#7273) 2023-06-09 16:08:40 +05:30
mail_with_inline_images.eml fix: Update inline image processing logic to fix missing images when multiple inline images present (#7861) 2023-09-06 14:35:19 +05:30
mail_with_invalid_to_2.eml fix: Raise error if email to_header is invalid (#8688) 2024-02-20 17:03:39 -08:00
mail_with_invalid_to.eml fix: Raise error if email to_header is invalid (#8688) 2024-02-20 17:03:39 -08:00
mail_with_no_date.eml fix: Use BODY.PEEK[HEADER] to avoid parsing issues with mail providers (#8833) 2024-02-01 17:24:59 -08:00
mail_with_no_subject.eml fix: Handle email with no subject line and no body (#2164) 2021-04-27 10:51:04 -07:00
mail_with_plain_text_and_inline_image.eml fix: Update inline image processing logic to fix missing images when multiple inline images present (#7861) 2023-09-06 14:35:19 +05:30
mail_with_quote.eml Fix: Email Parsing for html fix (#3659) 2022-01-20 15:55:35 -08:00
multiple_attachments.eml chore: fetch mails with multiple attachments (#7030) 2023-05-14 10:02:36 +05:30
multiple_in_reply_to.eml fix: Consider the emails where in-reply-to header has multiple values (#7715) 2023-08-11 17:53:57 -07:00
non_utf_encoded_mail.eml Fix: handling UTF encoded mail (#4384) 2022-04-06 12:36:32 +05:30
notification.eml chore: Prevent notification email loop (#3386) 2021-11-15 19:15:51 +05:30
only_attachments.eml Fix: html mail fix with html_body content (#4011) 2022-03-30 18:04:30 +05:30
only_html.eml Fix: html mail fix with html_body content (#4011) 2022-03-30 18:04:30 +05:30
only_text.eml Fix: html mail fix with html_body content (#4011) 2022-03-30 18:04:30 +05:30
references.eml fix: find mail message by references (#7220) 2023-05-31 19:23:29 +05:30
reply_cc.eml Fix: Find mailbox with cc email (#4372) 2022-04-08 11:20:19 +05:30
reply_mail_without_uuid.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
reply_to.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
reply.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
support_1.eml Fix: html mail fix with html_body content (#4011) 2022-03-30 18:04:30 +05:30
support_in_reply_to.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
support_uppercase.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
support_without_sender_name.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
support.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
welcome_html.eml chore: Improve email parsing using email trimmer gem (#3611) 2021-12-22 18:16:40 +05:30
welcome.eml fix: undefined method contact in support mailbox (#2678) 2021-08-12 01:28:07 +05:30