-
Notifications
You must be signed in to change notification settings - Fork 67
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
Feature/inline attachments #137
base: master
Are you sure you want to change the base?
Feature/inline attachments #137
Conversation
- provide functions for detecting inline attachments - implement a fast concatenation of a list of parts to a message - add helper method to separate parts into text/inline/attachment - wrap body and inline attachments in `multipart/related`
Hi there, First, thanks for this library. I'm trying this branch, and it works ok; I'm testing it with a set of .eml files, and it is parsed correctly. the only thing that is missing in this PR is the it is a little change though: def get_attachments(%Mail.Message{} = message) do
walk_parts([message], {:cont, []}, fn message, acc ->
case Mail.Message.is_any_attachment?(message) do
true ->
##### THIS
case Mail.Message.get_header(message, :content_disposition) do
["inline", {"filename", filename}] ->
{:cont, List.insert_at(acc, -1, {filename, message.body})}
["attachment", {"filename", filename}] ->
{:cont, List.insert_at(acc, -1, {filename, message.body})}
end
######
false ->
{:cont, acc}
end
end)
|> elem(1)
end |
@jarrodmoldrich thank you very much apoligies this went stale. I know it's a bit rediculous to ask after years but if you could just add regression tests for the additional behavior added I can merge this in. |
+1 |
Sorry, I've been off the radar, but I'm back! I'll have a look at this in the coming weeks. |
+1 |
@bcardarella Sorry for the delay. Added some tests. Let me know if you think this needs anything else. |
Hi @bcardarella do you think this one can go in now? |
that'lll be @andrewtimberlake's call |
Changes proposed in this pull request
For parts with
content-dispostion: inline
its important to reorganize themultipart
arrangement in the adapter. In particular it needs to be arrange liked this:My changes reorganize the parts as shown above, while maintaining backwards compatibility. It also adds matching functions for querying for inline attachments as for regular attachments. This change was required for inline images and
.ics
files to work properly, particularly in Outlook webmail.I've stopped short of adding tests to the test suite, and I'll wait for you to validate my approach first. I duplicated this code for
kalys/bamboo_ses
, where it currently functions well for my use cases: kalys/bamboo_ses#43Note: This PR also deprecates #133 as the original order of text parts should be maintained