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

Attachments with extension not in @mime_types fail #31

Open
MisterToolbox opened this issue Dec 28, 2015 · 4 comments
Open

Attachments with extension not in @mime_types fail #31

MisterToolbox opened this issue Dec 28, 2015 · 4 comments
Labels

Comments

@MisterToolbox
Copy link

Attaching a .docx, for instance, generates the following:

** (ArgumentError) argument error
        (stdlib) binary.erl:244: :binary.split/3
                 lib/mailman/attachment.ex:698: Mailman.Attachment.mime_type_for_path/1
                 lib/mailman/attachment.ex:668: Mailman.Attachment.inline/1
                 lib/mailman/attachment.ex:679: Mailman.Attachment.inline!/1
    (mothership) lib/mothership.ex:52: Mothership.attach_files/1
    (mothership) lib/mothership.ex:43: Mothership.generate_email/1
        (elixir) lib/enum.ex:1047: anonymous fn/3 in Enum.map/2
        (elixir) lib/enum.ex:1401: anonymous fn/3 in Enum.reduce/3
@Gidrek
Copy link

Gidrek commented Dec 29, 2015

I have to add mime type in my case.

I had en error with docx documents, I got unknown file. Anybody has fixed this?

@MisterToolbox
Copy link
Author

Manually adding this to @mime_types in attachments.ex will get you there.

    { ".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document" },

Ultimately, I'd think that mime_type_for_path(path) and mime_sub_type_for_path(path) should handle path being nil and default to application/octet

@Gidrek
Copy link

Gidrek commented Dec 29, 2015

We should do something like mailgun

file_parts = Enum.map(files, fn {field_name, file_name, file_content} ->
  [:lists.concat(['--', boundary]),
   :lists.concat(['Content-Disposition: format-data; name=\"', :erlang.atom_to_list(field_name), '\"; filename=\"', file_name, '\"']),
   :lists.concat(['Content-Type: ', 'application/octet-stream']),
   '',
   file_content]
end)

Where there is not mime type, just application-octet-stream like you said

@skosch
Copy link
Collaborator

skosch commented Sep 22, 2017

This should now be possible without having to hack attachments.ex – you can specify the mime type/subtype tuple directly via the attach/inline functions now.

@MisterToolbox, @Gidrek I know it's been over a year and a half, but if you're still using this it'd be great if you could give this a try and report back if it works for you.

@skosch skosch added the testing label Sep 22, 2017
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

3 participants