diff --git a/.gitignore b/.gitignore index bb18dc22..8b3949f7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /.elixir_ls erl_crash.dump *.ez +.DS_Store diff --git a/lib/bamboo/adapters/mailgun_adapter.ex b/lib/bamboo/adapters/mailgun_adapter.ex index b346065f..263f69ac 100644 --- a/lib/bamboo/adapters/mailgun_adapter.ex +++ b/lib/bamboo/adapters/mailgun_adapter.ex @@ -248,11 +248,18 @@ defmodule Bamboo.MailgunAdapter do Map.put(body, :attachments, attachment_data) end - defp prepare_file(%Attachment{} = attachment) do + defp prepare_file(%Attachment{content_id: nil} = attachment) do {"", attachment.data, {"form-data", [{"name", ~s/"attachment"/}, {"filename", ~s/"#{attachment.filename}"/}]}, []} end + # At the time of writing, Mailgun did not support clients specifying content id. + # Instead, they set the content id to be the given filename. + defp prepare_file(%Attachment{} = attachment) do + {"", attachment.data, + {"form-data", [{"name", ~s/"inline"/}, {"filename", ~s/"#{attachment.filename}"/}]}, []} + end + @mailgun_message_fields ~w(from to cc bcc subject text html template recipient-variables)a @internal_fields ~w(attachments)a