 
   defp auth(config), do: Base.encode64("api:#{config[:api_key]}")
 
-  defp content_type(%Email{attachments: nil}), do: "application/x-www-form-urlencoded"
-  defp content_type(%Email{attachments: []}), do: "application/x-www-form-urlencoded"
-  defp content_type(%Email{}), do: "multipart/form-data"
+  defp content_type(%{attachments: []}), do: "application/x-www-form-urlencoded"
+  defp content_type(%{}), do: "multipart/form-data"
 
   defp prepare_body(email) do
     %{}

    |> prepare_cc(email)
    |> prepare_bcc(email)
    |> prepare_reply_to(email)
    |> prepare_custom_vars(email)
  end

  # example custom_vars

  end
  defp prepare_custom_vars(body, _email), do: body

  defp prepare_attachments(body, %{attachments: []}), do: body
  defp prepare_attachments(body, %{attachments: attachments}) do
    Map.put(body, :attachments, Enum.map(attachments, &prepare_file(&1)))
  end

  defp prepare_file(attachment) do
    {:file, attachment.path,
     {"form-data",
      [{~s/"name"/, ~s/"attachment"/},
       {~s/"filename"/, ~s/"#{attachment.filename}"/}]},
     []}
  end

  defp prepare_from(body, %Email{from: from}), do: Map.put(body, :from, prepare_recipient(from))

