[GH-ISSUE #379] Inline images are listed among the attachments #247

Closed
opened 2026-03-15 13:26:25 +03:00 by kerem · 3 comments
Owner

Originally created by @tkoop on GitHub (Oct 25, 2024).
Original GitHub issue: https://github.com/axllent/mailpit/issues/379

If an email has an image in it with a disposition of "inline", it shows up in Mailpit as an attachment. The UI will say there is an attachment, but there isn't really.

Other email clients don't consider "inline" files to be attachments, so they shouldn't show up in Mailpit as attachments either.

For example, the html of the email may contain an inline png, like this:

<img src="cid:dc94e944fb73a7d82ed7da8350333ae6@symfony" alt="image">

When it does, there should also be a file included that matches the cid ("Content-id"), like this. (Also notice the Content-Disposition is "inline").

--w9GNgkGw
Content-ID: <dc94e944fb73a7d82ed7da8350333ae6@symfony>
Content-Type: image/png; name="dc94e944fb73a7d82ed7da8350333ae6@symfony"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 name="dc94e944fb73a7d82ed7da8350333ae6@symfony"; filename=embed0.png

iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAABhWlDQ1BJQ0MgcHJvZmlsZQAAKJF9
kT1Iw0AcxV9TpVoqDlYo4hCkOlkQFXHUKhShQqgVWnUwufRDaNKQtLg4Cq4FBz8Wqw4uzro6uAqC
4AeIs4OToouU+L+k0CLGg+N+vLv3uHsHCPUS06yOMUDTK2YqERcz2RUx8IogIuhHN4ZkZhmzkpSE
5/i6h4+vdzGe5X3uz9Gj5iwG+ETiGWaYFeJ14qnNisF5nzjMirJKfE48atIFiR+5rrj8xrngsMAz
w2Y6NUccJhYLbay0MSuaGvEkcVTVdMoXMi6rnLc4a6Uqa96TvzCU05eXuE5zEAksYBESRCioYgMl
VBCjVSfFQor24x7+AccvkUsh1wYYOeZRhgbZ8YP/we9urfzEuJsUigOdL7b9MQwEdoFGzba/j227
cQL4n4ErveUv14HpT9JrLS16BPRuAxfXLU3ZAy53gMiTIZuyI/lpCvk88H5G35QF+m6B4KrbW3Mf
pw9AmrpK3gAHh8BIgbLXPN7d1d7bv2ea/f0AaVtyo0qcczMAAAAGYktHRAAAAAAAAPlDu38AAAAJ
cEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfoChgVGzUMtjq8AAAAGXRFWHRDb21tZW50AENyZWF0
ZWQgd2l0aCBHSU1QV4EOFwAAADtJREFUOMtjnLzJ5z8DlQATAxUBC4yR67eFbEMmb/KhvstGiGEs
6IFICOCLqNEIGKAcMBoBdMwBdHMZAFlwC77XoVD6AAAAAElFTkSuQmCC
--w9GNgkGw

When this happens, the web UI shows this as an attachment, but it shouldn't. No other email client considers files like this to be attachments, so Mailpit shouldn't either.

image

image

If we really like the idea of listing all included files in the email, we should at least differentiate between attached files and inline files. Perhaps we could have two lists: a list of "Attachments", and a list of all "Included Files".

For the sake of completeness, this is what an actual attachment looks like. Notice the value of "Content-Disposition".

--frmTiHh9
Content-Type: application/pdf; name="abide.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; name="abide.pdf"; filename="abide.pdf"

JVBERi0xLjQKJcfsj6IKJSVJbnZvY2F0aW9uOiBncyAtc0RFVklDRT1wZGZ3cml0ZSAtZENvbXBh
dGliaWxpdHlMZXZlbD0xLjQgLWRQREZTRVRUSU5HUz0vcHJpbnRlciAtZE5PUEFVU0UgLWRRVUlF
VCAtZEJBVENIIC1zT3V0cHV0RmlsZT0/ID8KNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVy
IC9GbGF0ZURlY29kZT4+CnN0cmVhbQp4nH1by65syVEthISsYuBfKMmTc5DuJh+Rr6llC8wAuc2V
GGAzObhlQd2WjD8AIwb8Dp/jz2GtFZl776o6sq6660RUPiLjHZFZv7+FLd4C/83Pj2/Xv/1Vv338
4Rq2Prrlfnv94w8fP1zD7Uvbyq3GFG784z9/e/3+qpX09e+v0YH58fHt9tOvWDrG27h9/f7qu/H/
X/LWyu3rt+u/vF3+4vKz9y9hs25W29vlu/ewldhSy2+Xv+MXJbXWy9vlF+9fUi7bGIWDvvCvNDDh
X4G3vIUw3i5/rZVAcLG3yy81O46Y+9vlP9bCZlj4/h4jgIgpP7z/5us/kEhzImvoW0oNRH79t+vb
...
Originally created by @tkoop on GitHub (Oct 25, 2024). Original GitHub issue: https://github.com/axllent/mailpit/issues/379 If an email has an image in it with a disposition of "inline", it shows up in Mailpit as an attachment. The UI will say there is an attachment, but there isn't really. Other email clients don't consider "inline" files to be attachments, so they shouldn't show up in Mailpit as attachments either. For example, the html of the email may contain an inline png, like this: ``` <img src="cid:dc94e944fb73a7d82ed7da8350333ae6@symfony" alt="image"> ``` When it does, there should also be a file included that matches the cid ("Content-id"), like this. (Also notice the Content-Disposition is "inline"). ``` --w9GNgkGw Content-ID: <dc94e944fb73a7d82ed7da8350333ae6@symfony> Content-Type: image/png; name="dc94e944fb73a7d82ed7da8350333ae6@symfony" Content-Transfer-Encoding: base64 Content-Disposition: inline; name="dc94e944fb73a7d82ed7da8350333ae6@symfony"; filename=embed0.png iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAABhWlDQ1BJQ0MgcHJvZmlsZQAAKJF9 kT1Iw0AcxV9TpVoqDlYo4hCkOlkQFXHUKhShQqgVWnUwufRDaNKQtLg4Cq4FBz8Wqw4uzro6uAqC 4AeIs4OToouU+L+k0CLGg+N+vLv3uHsHCPUS06yOMUDTK2YqERcz2RUx8IogIuhHN4ZkZhmzkpSE 5/i6h4+vdzGe5X3uz9Gj5iwG+ETiGWaYFeJ14qnNisF5nzjMirJKfE48atIFiR+5rrj8xrngsMAz w2Y6NUccJhYLbay0MSuaGvEkcVTVdMoXMi6rnLc4a6Uqa96TvzCU05eXuE5zEAksYBESRCioYgMl VBCjVSfFQor24x7+AccvkUsh1wYYOeZRhgbZ8YP/we9urfzEuJsUigOdL7b9MQwEdoFGzba/j227 cQL4n4ErveUv14HpT9JrLS16BPRuAxfXLU3ZAy53gMiTIZuyI/lpCvk88H5G35QF+m6B4KrbW3Mf pw9AmrpK3gAHh8BIgbLXPN7d1d7bv2ea/f0AaVtyo0qcczMAAAAGYktHRAAAAAAAAPlDu38AAAAJ cEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfoChgVGzUMtjq8AAAAGXRFWHRDb21tZW50AENyZWF0 ZWQgd2l0aCBHSU1QV4EOFwAAADtJREFUOMtjnLzJ5z8DlQATAxUBC4yR67eFbEMmb/KhvstGiGEs 6IFICOCLqNEIGKAcMBoBdMwBdHMZAFlwC77XoVD6AAAAAElFTkSuQmCC --w9GNgkGw ``` When this happens, the web UI shows this as an attachment, but it shouldn't. No other email client considers files like this to be attachments, so Mailpit shouldn't either. ![image](https://github.com/user-attachments/assets/ae9af4ea-0ef4-4f91-8ea9-514c93c8c49c) ![image](https://github.com/user-attachments/assets/8c944324-c02e-4e3b-99a4-217363d8bd69) If we really like the idea of listing all included files in the email, we should at least differentiate between attached files and inline files. Perhaps we could have two lists: a list of "Attachments", and a list of all "Included Files". For the sake of completeness, this is what an actual attachment looks like. Notice the value of "Content-Disposition". ``` --frmTiHh9 Content-Type: application/pdf; name="abide.pdf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; name="abide.pdf"; filename="abide.pdf" JVBERi0xLjQKJcfsj6IKJSVJbnZvY2F0aW9uOiBncyAtc0RFVklDRT1wZGZ3cml0ZSAtZENvbXBh dGliaWxpdHlMZXZlbD0xLjQgLWRQREZTRVRUSU5HUz0vcHJpbnRlciAtZE5PUEFVU0UgLWRRVUlF VCAtZEJBVENIIC1zT3V0cHV0RmlsZT0/ID8KNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVy IC9GbGF0ZURlY29kZT4+CnN0cmVhbQp4nH1by65syVEthISsYuBfKMmTc5DuJh+Rr6llC8wAuc2V GGAzObhlQd2WjD8AIwb8Dp/jz2GtFZl776o6sq6660RUPiLjHZFZv7+FLd4C/83Pj2/Xv/1Vv338 4Rq2Prrlfnv94w8fP1zD7Uvbyq3GFG784z9/e/3+qpX09e+v0YH58fHt9tOvWDrG27h9/f7qu/H/ X/LWyu3rt+u/vF3+4vKz9y9hs25W29vlu/ewldhSy2+Xv+MXJbXWy9vlF+9fUi7bGIWDvvCvNDDh X4G3vIUw3i5/rZVAcLG3yy81O46Y+9vlP9bCZlj4/h4jgIgpP7z/5us/kEhzImvoW0oNRH79t+vb ... ```
kerem 2026-03-15 13:26:25 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@tkoop commented on GitHub (Oct 25, 2024):

Also note this. On the home page, the paper clip icon does show up correctly, only when disposition is "attachment", not when it is "inline".

image

<!-- gh-comment-id:2438665793 --> @tkoop commented on GitHub (Oct 25, 2024): Also note this. On the home page, the paper clip icon does show up correctly, only when disposition is "attachment", not when it is "inline". ![image](https://github.com/user-attachments/assets/925421b5-b529-4d9f-916d-75bb893b760d)
Author
Owner

@axllent commented on GitHub (Oct 25, 2024):

@tkoop Thanks for the details. You are correct, there is a discrepancy between the message list attachment indicator (paper clip) and the message view (Attachment (1)) which I will fix.

Backstory: Unfortunately there are actually huge discrepancies between mail clients, mainly in the generation of messages containing inline images. A number of clients do not actually use the Content-Disposition: inline; / Content-ID attributes - they just attach the file (like a regular attachment) and reference the filename as <img src="cid:<filename>" />. Because of this, many (most?) clients support displaying inline images even when they are attachments (and so does Mailpit).

Originally I catered for this in Mailpit by referring to both attachments and inline images as "attachments" in the web UI as well as the search, however that is wrong and at some point I decided this was a bad idea and changed it to the current behaviour. But, as you pointed out, there is still one artefact from that (...in the current versions of Mailpit, you're using an older version < v1.20.0 based on hour screenshots) - that being the Attachment (1) in the message view in your screenshot.

I need to give this a little more thought as to whether I just exclude inline images from that count, or whether I add a new Inline (1) tag to the message view (eg: a message with one attachment and two inline images could show Attachment (1) and Inlines (2)).

<!-- gh-comment-id:2438710053 --> @axllent commented on GitHub (Oct 25, 2024): @tkoop Thanks for the details. You are correct, there is a discrepancy between the message list attachment indicator (paper clip) and the message view (`Attachment (1)`) which I will fix. Backstory: Unfortunately there are actually huge discrepancies between mail clients, mainly in the generation of messages containing inline images. A number of clients do not actually use the `Content-Disposition: inline;` / `Content-ID` attributes - they just attach the file (like a regular attachment) and reference the filename as `<img src="cid:<filename>" />`. Because of this, many (most?) clients support displaying inline images even when they are attachments (and so does Mailpit). Originally I catered for this in Mailpit by referring to both attachments and inline images as "attachments" in the web UI as well as the search, however that is wrong and at some point I decided this was a bad idea and changed it to the current behaviour. *But*, as you pointed out, there is still one artefact from that (...in the current versions of Mailpit, you're using an older version < v1.20.0 based on hour screenshots) - that being the `Attachment (1)` in the message view in your screenshot. I need to give this a little more thought as to whether I just exclude inline images from that count, or whether I add a new `Inline (1)` tag to the message view (eg: a message with one attachment and two inline images could show `Attachment (1)` and `Inlines (2)`).
Author
Owner

@axllent commented on GitHub (Nov 1, 2024):

This change has been included in v1.21.1 👍 In relation to this clear(er) separation, there is also a new search filter has:inline which will filter by messages containing inline images. I'll close this issue now, but please feel free to re-open if you encounter and issues, thanks.

<!-- gh-comment-id:2451586373 --> @axllent commented on GitHub (Nov 1, 2024): This change has been included in [v1.21.1](https://github.com/axllent/mailpit/releases/tag/v1.21.1) :+1: In relation to this clear(er) separation, there is also a new search filter `has:inline` which will filter by messages containing inline images. I'll close this issue now, but please feel free to re-open if you encounter and issues, thanks.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#247
No description provided.